TST: add tests for index.groupby (GH5620)

Closes #5620

Also added a docstring.