Unit tests to the auth module.

Also added additional tests do the db module for features added in the
previous commit.