[fix bug 1000938] Proper filtering for group memberships.
Tests cleanup.