Correctly return resolved and reject promises.

Fixes #18.