add unit tests and javadoc