Add JavaDoc and some tests.