[VMRefactor] Implement a function to check for global scope 

Removes the clutter of what function to call or property to check when determining globalscope.
Refactor task does regress and does not require new testcases
@ke-yu  @lukechurch 

Done