Fixed a bug and added unit-tests for GlobalVariables