working hysteresis with gradient. add testcase for hysteresis