simplify grouping tests and clean up code