Rewrite tests to promises