adding promises fixed the test problem