Add more tests, fix database