Fixed some errors in database.c/h
Added database tests and ensured they work. Still more features to test on that front.