export module
jshint
Add unit tests.

Also, don't wrap error object when rejecting the promise. rather attach
additional info to it.