Cleaning up the getVar method
#1111: Querying the file of a Global constant ends in infinite loop

Due to a logical error in the ConstantDescriptor it would end up in an
infinite loop whenever the file is queried. This has been fixed in this
commit and a unit test has been added to verify this behaviour.