adding a test for the bug
test and fix (thx dgp)
fix var($) problem, bug [0c043a175] (thx dgp)
missing unset in new test
[0c043a175] backport fix from trunk.
Just a merge mark since fossil cannot do it right.