Generalize test to prepare for sparse matrices support.