allow trusted api to access the globals

In our usage of Sandcastle we want some context information available to the API methods we expose but not to the underlying scripts, by rearranging how sandbox populates globals vs api methods we can give api's access to the contextObject and allow it to make changes (so we can record the info we want and then delete it off the context object to hide it from the underlying user.

Added with example api and test.