Factor functionality into separate methods

Also pass down the error callback.
Test basic auth with the async transport