Added Java Test
Refactoring