But what is the output of the serial when you input40?
Because, except from the blocking nature of delay() and Serial.parseInt(), and the abuse of making everything int, I don't see anything weird.
And a small problem wit servo.read() is it may not return the same angle was you wrote. This is because it converts it to the number of tick it needs and back again when you do a .read(). But probably not an issue here.