refactoring tests and adding javadocs