Changed global declaration to local.
Updated unit tests to work with new changes.