added test to discover error in sum_mats. fixed sum_mats, now test passes. Does it fix all the funny runs?