Modified switching function test to check against analytical gradient instead of finite-difference.