Fixed tests to work with dense output
Merge branch 'flattener-sparse-matrix' into develop