added support to return a list of group memberships

These couple of lines look a little hairy/messy to me, though I'm not quite sure to write them in a neater way.

We do however here assume that we get a non-empty list back.