Decouple connection from groups queries.

This way we can perform search with groups easily.
Extract membership method to be able to retried groups that a user belong to.
Fix indentation.
Merge pull request #1 from github/better_groups

Decouple connection from group queries.