 
   it 'should send HTTP 400 when user is unregistered but alreadyMember set to true', (done) ->
 
-    createTeamRequestParams = generateCreateTeamRequestParams
-      body            :
-        alreadyMember : 'true'
-
-    # expecting user to create team when alreadyMember has wrong value
-    request.post createTeamRequestParams, (err, res, body) ->
-      expect(err)             .to.not.exist
-      expect(res.statusCode)  .to.be.equal 400
-      expect(body)            .to.be.equal 'Unknown user name'
-      done()
+    generateCreateTeamRequestParams {
+      body : { alreadyMember : 'true' }
+    }, (createTeamRequestParams) ->
+
+      # expecting user to create team when alreadyMember has wrong value
+      request.post createTeamRequestParams, (err, res, body) ->
+        expect(err)             .to.not.exist
+        expect(res.statusCode)  .to.be.equal 400
+        expect(body)            .to.be.equal 'Unknown user name'
+        done()
 
 
   it 'should send HTTP 400 when email is not valid', (done) ->
 
     # setting email as random string
-    createTeamRequestParams = generateCreateTeamRequestParams
-      body    :
-        email : generateRandomString 10
-
-    request.post createTeamRequestParams, (err, res, body) ->
-      expect(err)             .to.not.exist
-      expect(res.statusCode)  .to.be.equal 400
-      done()
+    generateCreateTeamRequestParams {
+      body : { email : generateRandomString(10) }
+    }, (createTeamRequestParams) ->
+
+      request.post createTeamRequestParams, (err, res, body) ->
+        expect(err)             .to.not.exist
+        expect(res.statusCode)  .to.be.equal 400
+        done()
 
 
   it 'should send HTTP 400 when email is in use and username is not in use', (done) ->

JSession                            = null
JInvitation                         = null
JDomainAlias                        = null


# here we have actual tests

    groupId                 = ''
    username                = generateRandomString()
    accountId               = ''

    queue = [

      ->
        generateCreateTeamRequestParams {
          body : { username, slug }
        }, (createTeamRequestParams) ->

          # expecting HTTP 200 status code
          request.post createTeamRequestParams, (err, res, body) ->
            expect(err)             .to.not.exist
            expect(res.statusCode)  .to.be.equal 200
            queue.next()

      ->
        # expecting user to be saved and holding userId
