Using algebraic long division we have:
.......kx^2+(k^2+5)x+k(k^2-2)
x-k | kx^3 + 5x^2 ..........-7kx............-8
........kx^3-k^2x^2
..........(k^2+5)x^2..........-7kx
..........(k^2+5)x^2-k(k^2+5)x
.............................k(k^2-2)x-............-8
.............................k(k^2-2)x-k^2(k^2-2)
............................................................0
The remainder is zero so k^2(k^2-2)-8=0; k^4-2k^2-8=0, (k^2-4)(k^2+2)=0, so k=2.
The quotient is: 2x^2+9x+4=(2x+1)(x+4).