Refactor promises, write specs