xhr: Wrote tests for xhr.js

- [ ] @davestein
Previous two lines attaches callbacks at wrong time.