small refactoring of method fix_wrong_memberships_count()