Update tests and fix error handling

Just making sure the returned promise is always either resolved or
rejected.