Add test and javadoc