add some tests, do some minor changes to database structure