add testcases for recently fixed misscoping bug

see commit 877438d7a067e19af1ff3877469f38f2ca90628d