>>>Most of that is the same as the OP's code.
Well, yes but there are important modifications. I think the OP's script simply had a mislabeled variable, which caused the failure.
The version above works only if someHandler is a property. If you note out that line it fails.
So even though handlers are global in scope, for some reason you can't set a local variable to a handler, but you can set a global variable or a property to a handler.
(In your previous example, the variable wasn't a property, but it was global, not local.)