db unit test and small fixes