add more junit test and refactoring