Throw networking issue in XHR as NetworkingError
Don't emit http events if status code is 0

Fixes issue where networking errors (like CORS failure) would emit
the 'readystatechange' event in Firefox browsers with a status code of
0 in addition to the 'error' event, causing both the 'success' and
'error' events to fire in the SDK for the request.

Fixes #203
Refactor XHR code to reduce method complexity
Add integration test for #203