Improve response and dispatch event in AuthenticationFailureHandler

Response status code is changed from ``401 (Unauthorized)`` to ``400 (Bad Request)`` (see http://stackoverflow.com/a/1960453). I think this makes more sense if the login parameters are invalid.

Response is now a valid json object containing a ``code`` and a ``message`` attributes.

The handler now dispatch a failure event.