             aFilter =
                 afterTimeout: (callback) ->
                     callback()
-                    setTimeout ->
+                    setImmediate ->
                         done()
-                    , 30
                 before: ->
                     # The callback is not called, so the controller.get() will never be called
                     # Therefore controller.afterTimeout() should also not be called!
             controller =
-                afterTimeout: -> expect.fail()
+                afterTimeout: -> expect().fail()
                 method: 'get'
                 filters: [aFilter]
-                get: -> expect.fail()
+                get: -> expect().fail()
 
             runner.run controller, 100, (error) ->
                 expect(error.name).to.be 'Timeout'

                filters: []
                method: 'get'
                before: (callback) -> beforeCalled = true ; callback(true)
                after: -> expect.fail()
                get: ->
                afterTimeout: ->
                    expect(beforeCalled).to.be true

            aFilter =
                afterError: (callback) ->
                    callback()
                    setImmediate ->
                        done()
                before: ->
                    setImmediate ->
                        throw name: 'MyError'
            controller =
                afterError: -> expect().fail()
                method: 'get'
                filters: [aFilter]
                get: -> expect().fail()

            runner.run controller, 10000, (error) ->
                expect(error.name).to.be 'MyError'

        it 'should not call bFilter.afterError() if an exception occurs within the aFilter.before()', (done) ->
            aFilter =
                afterError: (callback) ->
                    callback()
                    setImmediate ->
                        done()
                    , 30
                before: ->
                    setImmediate ->
                        throw name: 'MyError'
            bFilter =
                afterTimeout: -> expect().fail()
            controller =
                method: 'get'
                filters: [aFilter, bFilter]
                get: -> expect().fail()

            runner.run controller, 10000, (error) ->
                expect(error.name).to.be 'MyError'
