require Global.app to be set before creating a GlobalID

fix #5

I'm not sure if it's a good idea to reset GlobalID.app like this way. But I didn't find a better way by now.
Use `begin ... ensure ... end` to guarantee that GlobalID.app is set back to its original value even if an exception was raised.