Fix gradient test to (hopefully) not depend on rounding behavior.