 
       it 'should be able to update the stack template', (done) ->
 
-        withConvertedUser ({ client }) ->
-
-          stackTemplate     = null
-          stackTemplateData = null
+        withConvertedUserAndStackTemplate (data) ->
+          { client, stackTemplate, stackTemplateData } = data
 
           queue = [
-
-            ->
-              stackTemplateData = generateStackTemplateData client
-              StackTemplate.create client, stackTemplateData, (err, template_) ->
-                expect(err).to.not.exist
-                stackTemplate = template_
-                queue.next()
 
             ->
               params = { title : 'title should be updated' }


      it 'should be able to set access level of stack template', (done) ->

        withConvertedUser ({ client }) ->

          stackTemplate     = null
          stackTemplateData = null

          queue = [

            ->
              stackTemplateData = generateStackTemplateData client
              StackTemplate.create client, stackTemplateData, (err, template_) ->
                expect(err).to.not.exist
                stackTemplate = template_
                queue.next()

            ->
              stackTemplate.setAccess client, 'someInvalidAccessLevel', (err) ->


      it 'should be able to fetch stack template data', (done) ->

        withConvertedUserAndStackTemplate (data) ->
          { client, stackTemplate, stackTemplateData } = data
          selector = { _id : stackTemplate._id }

          StackTemplate.some$ client, selector, (err, templates) ->
            expect(err?.message).to.not.exist
            expect(templates[0].title).to.be.equal stackTemplateData.title
            expect(templates[0].template.content).to.be.deep.equal stackTemplateData.template
            done()


  describe '#one$()', ->
