[SPARK-3418] Fixed failing Matrix unit test