fix how the onMessage is implemented and updated the mock to reflect the change.