 
     request.post createTeamRequestParams, (err, res, body) ->
       expect(err)             .to.not.exist
-      expect(res.statusCode)  .to.be.equal 500
-      expect(body)            .to.be.equal 'Couldn\'t create the group.'
-      done()
-
-
-  it 'should send HTTP 500 when slug is set as koding', (done) ->
+      expect(res.statusCode)  .to.be.equal 400
+      expect(body)            .to.be.equal 'Group slug can not be empty.'
+      done()
+
+
+  it 'should send HTTP 403 when slug is set as koding', (done) ->
 
     createTeamRequestParams = generateCreateTeamRequestParams
       body   :
         slug : 'koding'
 
-    request.post createTeamRequestParams, (err, res, body) ->
-      expect(err)             .to.not.exist
-      expect(res.statusCode)  .to.be.equal 500
-      expect(body)            .to.be.equal 'Couldn\'t create the group.'
-      done()
-
-
-  it 'should send HTTP 400 when email is in use', (done) ->
+    expectedBody = 'Sorry, Team URL \'koding.koding.com\' is already in use'
+    request.post createTeamRequestParams, (err, res, body) ->
+      expect(err)             .to.not.exist
+      expect(res.statusCode)  .to.be.equal 403
+      expect(body)            .to.be.equal expectedBody
+      done()
+
+
+  it 'should send HTTP 403 when slug is set as an already used one', (done) ->
+
+    slug                    = generateRandomString()
+    createTeamRequestParams = generateCreateTeamRequestParams
+      body   :
+        slug : slug
+
+    queue = [
+
+      ->
+        # expecting first team create request to be successful
+        request.post createTeamRequestParams, (err, res, body) ->
+          expect(err)             .to.not.exist
+          expect(res.statusCode)  .to.be.equal 200
+          queue.next()
+
+      ->
+        # expecting second team crete request with the same slug to fail
+        expectedBody = "Sorry, Team URL '#{slug}.koding.com' is already in use"
+        request.post createTeamRequestParams, (err, res, body) ->
+          expect(err)             .to.not.exist
+          expect(res.statusCode)  .to.be.equal 403
+          expect(body)            .to.be.equal expectedBody
+          queue.next()
+
+      -> done()
+
+    ]
+
+    daisy queue
+
+
+  it 'should send HTTP 200 when user is registered but alreadyMember set to false', (done) ->
 
     email                   = generateRandomEmail()
+    username                = generateRandomString()
+    password                = 'testpass'
     registerRequestParams   = RegisterHandlerHelper.generateRequestParams
-      body    :
-        email : email
-
-    createTeamRequestParams = generateCreateTeamRequestParams
-      body    :
-        email : email
+      body              :
+        email           : email
+        username        : username
+        password        : password
+        passwordConfirm : password
+
+    createTeamRequestParams = generateCreateTeamRequestParams
+      body              :
+        email           : email
+        alreadyMember   : 'false'
+        username        : username
+        password        : password
+        passwordConfirm : password
 
     queue = [
 

      body        :
        invitees  : inviteeEmail

    { slug
      email
      domains

    daisy queue


  it 'should send HTTP 400 when company is not set', (done) ->

    createTeamRequestParams = generateCreateTeamRequestParams
      body          :
