Replace process.nextTick by setImmediate if supported