Added some tests of the matrix functionality and squashed some bugs.