Added groupWithM unit tests