Some small improvements.

Signed-off-by: Dmitry Gryazin <dosagc@gmail.com>
Add JUnit tests.

Signed-off-by: Dmitry Gryazin <dosagc@gmail.com>