     it "has no idea about unkown accounts", (done) ->
         db.verify_email_check_token(email_address:"other-one@test.com", token:locals.token, cb: (err) ->
             expect(!!err).toBe(true)
-            done()
+            expect(err.indexOf('no such account') != -1).toBe(true)
+            done(undefined)  # suppress error
         )
 
     it "detects a wrong token", (done) ->
         async.waterfall([
             (cb) -> db.create_account(first_name:"C", last_name:"D", created_by:"1.2.3.4", email_address:locals.email_address2, password_hash:"test", cb: cb)
             (account_id, cb) -> db.verify_email_create_token(account_id: account_id, cb:cb)
-            (token, cb) ->
-                db.verify_email_check_token(email_address:locals.email_address2, token:"X", cb: (err) ->
-                    expect(err.indexOf('token does not match') != -1).toBe(true)
-                    cb()
-                )
+            (token, email_address, cb) ->
+                expect(email_address).toBe(locals.email_address2)
+                db.verify_email_check_token
+                    email_address    : locals.email_address2
+                    token            : "X"   # a wrong one
+                    cb               : (err) ->
+                        expect(err.indexOf('token does not match') != -1).toBe(true)
+                        cb(undefined) # suppress error
         ], done)
 
     it "returns the verified email address", (done) ->
-        db.verify_email_get(account_id:locals.account_id, cb:(err, x) ->
-            verified = x.email_address in misc.keys(x.email_address_verified)
-            expect(verified).toBe(true)
-            done()
-        )
+        db.verify_email_get
+            account_id    : locals.account_id
+            cb            : (err, x) ->
+                verified = x.email_address in misc.keys(x.email_address_verified)
+                expect(verified).toBe(true)
+                done(err)
 
     it "and also answers is_verified_email correctly", (done) ->
-        db.is_verified_email(email_address:locals.email_address, cb: (err, verified) ->
-            expect(verified).toBe(true)
-            done()
-        )
-
+        async.series([
+            (cb) ->
+                db.is_verified_email
+                    email_address : locals.email_address
+                    cb            : (err, verified) ->
+                        expect(verified).toBe(true)
+                        cb(err)
+
+            (cb) ->
+                db.is_verified_email
+                    email_address : locals.email_address2
+                    cb            : (err, verified) ->
+                        expect(verified).toBe(false)
+                        cb(err)
+        ], done)
 
 describe 'working with accounts: ', ->
     @timeout(5000)

COPYRIGHT : (c) 2017 SageMath, Inc.
LICENSE   : AGPLv3
###

pgtest   = require('./pgtest')
db       = undefined

            for char in token
                expect(char in '0123456789abcdefghijklmnopqrstuvwxyz').toBe(true)
            locals.token = token
            done(err)
        )

    it "correctly checks the token", (done) ->
