 		
 		assert.eventuallyThrows = ( error, done, timeout = 50 ) ->
 			originalHandler = window.onerror
-			onErrorStub = sinon.stub().returns( true )
-			window.onerror = onErrorStub
-			setTimeout( 
+			restored = false
+			window.onerror = ( message ) ->
+				window.onerror = originalHandler
+				restored = true
+				expect( message ).to.contain( error.message )
+				done()
+				return
+			setTimeout(
 				->
-					window.onerror = originalHandler
-					try
-						expect( onErrorStub ).to.be.calledOnce
-						expect( onErrorStub.lastCall.args[ 0 ] ).to.contain( error.message )
-						done()
-					catch error
-						done( error )
+					if not restored
+						window.onerror = originalHandler
+						done( new Error( 'expected ' + error + ' to be thrown within ' + timeout + 'ms' ) )
 				timeout
 			)
 			return

			specify( 'called in specified scope if rejected', ( done ) ->
				targetScope = {}
				onRejected = sinon.spy()
				
				promise = Deft.Deferred.reject( new Error( 'error message' ) )
				promise.otherwise( onRejected, targetScope )
				
				promise.then(
					null
					->
						try
							expect( onRejected ).to.be.calledOnce.and.calledWith( new Error( 'error message' ) ).and.calledOn( targetScope )
							done()
						catch error
							done( error )

				promise.should.be.an.instanceof( Deft.Promise )
				promise = promise.then(
					( value ) -> 
						expect( now() - start ).to.be.closeTo( 100, 50 )
						return value
				)
				return promise.should.eventually.equal( undefined )
