Database tests

Initial database tests. I can't think of anything else to test so far. Comment if you think of something, and I'll make it up.