Add more javadoc and tests