bug fixes, database now passing tests