Added test to test for numerical issues just fixed
Changed calculation of math.sqrt to avoid numerical problems when re < 0