Fixed compile time bug in matrix class.

Added some test cases for matrices.