refactor daos and the corresponding tests