add javadoc and tests