fix response from before_action event listener, add unit tests for returning responses from event listeners
simplify output buffer handling