Test fixes for upstream globalize and some refactoring

These changes get the tests passing with the upstream version of
globalize.