Add more useful error methods to the API login.

Post a `jsonify` response to the API.

Using a simple dict did not work.

Finally, tests are still failing because `jsonify`
is used outside of the application context.