added some test cases and more logic for groups