Code reformatted.
Added JavaDoc
Added test cases
Added utility for unit test
Some minor fix