Switch to Promise-based API. Add tests for XHR.