Fix global identity testing.

Heavily inspired by https://github.com/brianmcd/node/commit/e53301bdd8fe9d66d3ca0a3b91eb96c8dddb97d9.