Refactor EventSource for Testing