removing timeout and adding event listeners to speed up tests