Add test for scoping bug

See #9