Fix CSV output of matrices to be in column-major order, consistent with the header output..
Additional unit testing for CSV output of matrices.