Allow custom xhr factory similar to jQuery.

This allows users to supply a custom `xhr` factory in the options, similar to the [jQuery](http://api.jquery.com/jQuery.ajax/#options) one
My use case is to integrate [libxdr](https://github.com/eligrey/libxdr) so that CORS requests work 100% in IE8/9, but this is flexible enough for other use cases.

At first glance, this would also allow to easily mock XmlHttpRequest compatible instances in tests. 

This PR is actually very simple and includes tests :)