     authenticationCallback = (err, user) ->
       assert.ok user, "Expected user to be returned when authentication successful"
       assert.strictEqual "hats", user.email
-
       done()
 
     user.loginFromLocalDb("boats", authenticationCallback)
-  ).fail( (err) ->
-    console.error err
-    throw err
-  )
+  ).fail(done)
 )
 
 test(".loginFromLocalDb fails if the user's password is incorrect", (done) ->

  user = new User(distinguishedName: dn)

  user.save( (err, savedUser) ->
    if err?
      console.error err
      throw new Error(err)

    assert.strictEqual(
      dn,

  ).then( (user) ->
    callback = (err, user) ->
      assert.notOk user, "Expected user to not be returned when authentication fails"
      done()

    user.loginFromLocalDb("ships", callback)
  ).fail(done)
)

test("Usernames must be unique", (done) ->
  helpers.createUser().then( (user) ->
    helpers.createUser()
  ).then( ->
    done(new Error("Expected duplicate user creation to fail"))
  ).fail( (err) ->
    console.error err
    assert.match err, /duplicate key error index/
    done()
  )
)
