Added event listening, plus tests