Added tests to complete coverage
Refactor - moved group matrix generation to util module