Return HTTP code 400 instead of 500 for bad request