Fixed direct setImmediate calls that caused tests to fail.