Fix to database.js

Off by one error :(
Syntax fix
Adding newlines to unit tests
better date comparison