Added test for matrix pattern
Refactoring.
Extracted matrix pattern splitting out of the other function
Refactoring.
Extracted splitting with row pattern