some database fixes and test cases