Sort test and HashMatrixDimension fix