Made window and document overridable by adding an init function