refactored tests a bit to rescue setTimeout freezing