apply new design for test code and fixed SparseMatrix constructor bug