return 400/500 codes correctly