xhr: refactoring and style changes to xhr.js tests