Fix test and release db after test

Add a statement to force close the db
Fix test with more assertions and add test for assertions on db schema