slightly refactor test_expect for operators to use correct variance
Created by: PhilipVinc
This PR changes the logic used to compute the distance between two gradients (i believe the old one was partly broken). Also the error tolerance now depends on the variance of the local energy.
Taken from #1065 . I want to merge the changes to the tests separately and be sure you agree with them.