fix bug where using same name for var was overwriting previous
scope
fix broken tests and add test for previous commit