         indicator: indicator._id
       }]
 
-    request.post({
-      url: helpers.appurl('api/pages/')
-      json: true
-      body: data
-    },(err, res, body) ->
-      id = body._id
-
-      assert.equal res.statusCode, 201
-
-      assert.property body, 'sections'
-      assert.lengthOf body.sections, 1
-      assert.isDefined body.sections[0]._id, "New page Section not assigned an ID"
-      assert.equal body.sections[0].title, data.sections[0].title
-
-      assert.equal body.sections[0].indicator.title, indicator.title
-
-      Page
-        .findOne(_id: id)
-        .exec( (err, page) ->
-          assert.equal page.title, data.title
-          done()
-        )
-    )
+    Q.nfcall(
+      request.post, {
+        url: helpers.appurl('api/pages/')
+        json: true
+        body: data
+      }
+    )
+
+  ).then( (res, body) ->
+
+    # Assert expected outcomes
+    id = body._id
+
+    assert.equal res.statusCode, 201
+
+    assert.property body, 'sections'
+    assert.lengthOf body.sections, 1
+    assert.isDefined body.sections[0]._id, "New page Section not assigned an ID"
+    assert.equal body.sections[0].title, data.sections[0].title
+
+    assert.equal body.sections[0].indicator.title, indicator.title
+
+    Page
+      .findOne(_id: id)
+      .exec( (err, page) ->
+        assert.equal page.title, data.title
+        done()
+      )
+
+  ).fail((err) ->
+    console.error err
+    throw err
   )
 )
 

  async.series([helpers.createSection, helpers.createSection], createPageWithSection)
)

test('POST create - nesting a section in a page', (done) ->
  helpers.createIndicator({title: 'dat indicator'}, (err, indicator) ->
    data =
      title: "new page"
      sections: [{

url = require('url')
_ = require('underscore')
async = require('async')
passportStub = require 'passport-stub'
Q = require 'q'

suite('API - Page')

