Finihsed matrix files and added all test cases for the new code