added javadoc comments and tests