Fix queries in groups and tests controller