updated the test cases and updated the code according to pmd checks