fix tests
refactoring
add javadoc
add some untested methods to merge files