Merge "Introduce onEvent() to improve testability"