changed var allowLocationChange = false to this.allowLocationChange and refactored in order to allow setting of variables in unit tests.