 
             (next) ->
               # create a session for AdminAccount to be able to create resources
-              JSession = require './session'
-              sessionOptions =
-                username  : account.getAt 'profile.nickname'
-                groupName : group2Slug
-
-              JSession.createNewSession sessionOptions, (err, session) ->
-                expect(err).to.not.exist
-
-                adminClient =
-                  sessionToken : session.clientId
-                  context      : { group: group2Slug }
-                  clientIP     : '127.0.0.1'
-                  connection   :
-                    delegate   : account
-
+              createCustomClient group2Slug, account, (err, client_) ->
+                adminClient = client_
+                expect(err).to.not.exist
                 next()
 
             (next) ->
               # creating resources for group2 for adminAccount
               createResourcesQueue = [
                 (next) ->
+
                   provider = 'aws'
-
-                  options =
+                  options  =
                     meta     : generateMetaData provider
                     title    : 'someCredentialTitle'
                     provider : provider
 
-                  options.meta.foobar = '  trim this white space   '
                   JCredential.create adminClient, options, (err, credential) ->
                     expect(err).to.not.exist
                     expect(credential).to.exist
                     next()
 
                 (next) ->
-                  stackTemplateData = generateStackTemplateData adminClient
+                  data = { machines: generateStackMachineData 1 }
+                  stackTemplateData = generateStackTemplateData adminClient, data
                   JStackTemplate.create adminClient, stackTemplateData, (err, template) ->
                     expect(err).to.not.exist
                     expect(template).to.exist

              expect(creds.length).to.be.equal 0
              next()


          (next) ->
            JStackTemplate.some { originId: account.getId() }, {}, (err, stackTemplates) ->

  withDummyClient
  withConvertedUser
  generateDummyClient
  generateUserInfo
  createCustomClient
  generateRandomString
  generateRandomEmail
  checkBongoConnectivity } = require '../../../testhelper'

{ createUserAndMachine } = require '../../../testhelper/models/computeproviders/machinehelper'

{ generateMetaData } = require \
  '../../../testhelper/models/computeproviders/credentialhelper'
