Fix issues with running tests, refactor to promises