     candidate = "#{username}@#{host}"
 
     validateEmailRequestParams = generateValidateEmailRequestParams
-      body     :
-        email  : candidate
+      body    :
+        email : candidate
 
     # expecting email validation to fail using already registered email
     request.post validateEmailRequestParams, (err, res, body) ->
-      expect(err)             .to.not.exist
-      expect(res.statusCode)  .to.be.equal 400
-      expect(body)            .to.be.equal 'Bad request'
+      expect(err).to.not.exist
+      expect(res.statusCode).to.be.equal 400
+      expect(body).to.be.equal 'Bad request'
       done()
 
 
   it 'should send HTTP 400 if email is in use and password is invalid', (done) ->
 
-    email     = generateRandomEmail()
-    username  = generateRandomUsername()
-    password  = 'testpass'
+    email    = generateRandomEmail()
+    username = generateRandomUsername()
+    password = 'testpass'
 
     registerRequestParams = generateRegisterRequestParams
       body              :


    queue = [

      ->
        # registering a new user
        request.post registerRequestParams, (err, res, body) ->
          expect(err)             .to.not.exist
          expect(res.statusCode)  .to.be.equal 200
          expect(body)            .to.be.equal ''
          queue.next()

      ->
        # setting two factor authentication on by adding twofactorkey field
        JUser.update { username }, { $set: { twofactorkey: 'somekey' } }, (err) ->
          expect(err).to.not.exist
          queue.next()

      ->
        # expecting 400 for the 2fa enabled account
        request.post validateEmailRequestParams, (err, res, body) ->
          expect(err)             .to.not.exist
          expect(res.statusCode)  .to.be.equal 400
          expect(body)            .to.be.equal 'TwoFactor auth Enabled'
          queue.next()

      -> done()

    ]

    daisy queue


  it 'should send HTTP 200 if email is in use and password is valid', (done) ->

{ async
  expect
  request
  generateRandomEmail
  generateRandomString
  generateRandomUsername
  checkBongoConnectivity }             = require '../../../testhelper'
{ generateRegisterRequestParams }      = require '../../../testhelper/handler/registerhelper'
{ generateValidateEmailRequestParams } = require '../../../testhelper/handler/validateemailhelper'

JUser = require '../../../models/user'


beforeTests = -> before (done) ->

  checkBongoConnectivity done


# here we have actual tests
runTests = -> describe 'server.handlers.validateemail', ->

  it 'should send HTTP 404 if request method is not POST', (done) ->

    validateEmailRequestParams = generateValidateEmailRequestParams
      body    :
        email : generateRandomEmail()

    queue   = []
    methods = ['put', 'patch', 'delete']

    addRequestToQueue = (queue, method) -> queue.push (next) ->
      validateEmailRequestParams.method = method
      request validateEmailRequestParams, (err, res, body) ->
        expect(err).to.not.exist
        expect(res.statusCode).to.be.equal 404
        next()

    for method in methods
      addRequestToQueue queue, method

    async.series queue, done


  it 'should send HTTP 400 if email is not set', (done) ->
