 
       'with no options':
         topic: -> factory()
+
         'should call connector.request':
           calledOnce withEmptyOptions returningRequestObject()
 
       'with data':
         topic: ->
-          factory data: {
+          data =
             message: 'Hello World!'
             fn: -> 'Goodbye World!'
-          }
-
-        'should call connector.request': ->
+
+          context = factory data: data
+          context.data = data
+          context
+
+        'should call connector.request':
           calledOnce returningRequestObject
 
             'with headers': ({ request }) ->
-              assert.notEmpty headers = request.getCall(0).args[0].headers
+              assert.ok headers = request.getCall(0).args[0].headers
               assert.strictEqual headers['Content-Type'], 'application/json'
               assert.isTrue headers['Content-Length'] > 0
 
             'with json parsable data': ({ request, data }) ->
               js = null
-              json = request.getCall(0).args[0].data
-              assert.notEmpty json
+              assert.ok json = request.getCall(0).args[0].data
               assert.doesNotThrow (-> js = JSON.parse(json) ), SyntaxError
               assert.strictEqual js.message, data.message
-              assert.match js.fn /\bfunction(\s|\\n)*\(\)(\s|\\n)*{(\s|\\n)*\breturn\b(\s|\\n)*'Goodbye World!'(\s|\\n)*;(\s|\\n)*}/
+              assert.match js.fn, ///
+                \b
+                  function (\s|\\n)* \(\) (\s|\\n)* \{ (\s|\\n)*
+                    \b return \b (\s|\\n)* 'Goodbye\sWorld!' (\s|\\n)* ; (\s|\\n)*
+                  \}
+              ///
 
       'with data emitter':
         topic: -> factory data: on: sinon.stub()

  withEmptyOptions = (context = {}) ->
    context['with empty options'] = ({ request }) ->
      arg0 = request.getCall(0).args[0]
      assert.isEmpty arg0 if typeof arg0 isnt 'undefined'
    context

  returningRequestObject = (context = {}) ->

          'with response callback': ({ requestObject }) ->
            assert.isTrue requestObject.on.calledWith 'response'

          'with response handler to':
            topic: ({ callback, requestObject }) ->
              responseObject =
                on: sinon.stub()
