Fixed: bug form error response code

This PR fixes issue #577 and #578