 
     describe 'when called with an invalid request', ->
       beforeEach (done) ->
+        @eventForwarder.on 'message', (@message) =>
+          done() if @message.topic == 'devices-error'
         @meshblu.devices {uuid: 'invalid-uuid'}, =>
-          @eventForwarder.once 'message', (@message) =>
-            done()
 
       it 'should send a "devices-error" message', ->
         expect(@message.topic).to.deep.equal 'devices-error'

  describe 'EVENT unregister', ->
    describe 'when called with a valid request', ->
      beforeEach (done) ->
        @meshblu.register {}, (data) =>
          return done new Error data.error if data.error?

          @newDevice = data
          @meshblu.unregister uuid: @newDevice.uuid, (data) =>
            return done new Error data.error if data.error?
            @eventForwarder.once 'message', (@message) =>
              done()

      it 'should send a "unregister" message', ->
        expect(@message.topic).to.deep.equal 'unregister'


    describe 'when called with an invalid request', ->
      beforeEach (done) ->
        @eventForwarder.on 'message', (@message) =>
          done() if @message.topic == 'unregister-error'

        @meshblu.unregister uuid: 'invalid-uuid', (error) =>

      it 'should send an "unregister-error" message', ->
        expect(@message.topic).to.deep.equal 'unregister-error'
