(maint) Add leaky local scope tests

This adds tests that local and match scope handling is corrent
and does not leak variable bindings.