Performed  refactoring for test and DAo logic