Added unit test and some javadoc