Junit test cases and bug fixes.