Better database tests.
Slight changes to database API