refactoring to return httpresponse instead of string (not test)