added javadoc and tests