Adding test cases + adjusting exceptions

Exceptions where thrown like in the GroupingTest.java.
InvalidProgramException and IllegalArgument and IndexOutofBound
Exceptions are used.
Renamed