Fixed variable name resolution
Updated tests