Add unit tests for adapter ajaxError function.

Also:

* Modified ajaxError() to make the behaviour more explicit when the
  responseText can't be parsed.
* Improved comments.