setTimeout -> setImmediate

Simple change. Passes tests and should work everywhere. Testing time (for me) is reduced from 780ms to 730ms.