Fix test matrix generation to be scalable