Replaced deprecated process.nextTick with setImmediate

- Added test that causes Maximum call stack size exeeded error in node
when not using setImmediate