Improve javadoc. Add new tests