[minor] Move the readyStateChange events to a proper prototype instead of a scope.