factor out json_response to common
clean up response processing
Cleanup so that tests are passing