I haven't tested this, but you should even be able to simplify it further by using the single line:
As for it not working, the best guesses I have are that you put spaces or line breaks between an
$if( and the following comma (extra characters make it think that the test succeeded every time) or you put the lines in a script with some error that passes the parser but fails when run (rare, but that's why @mfmeulenbelt recommended making a new script). And, just to be sure, you aren't putting it in the box on the file renaming page, are you? That will still run as long as you have renaming enabled, but only once you save the file, so you may not see any change.
If none of that's what's wrong, I'm not entirely sure what's going on. I know I've had issues with
$unset in the past myself, but I forget how I fixed them then. Sorry!