minor refactor and unit test fix
database module complete