Use a solution from http://www.adequatelygood.com/Replacing-setTimeout-Globally.html to make global methods replaceable.