Added further test cases and javadoc.