Added test to assert the number of evaluations when setting a variable

Closes #309

The problem seems to be fixed, but i added the test to guarantee.