fix flaky test EXPECT_EQ code
fix flaky math functions, remove unnecessary instantiations.