Add a test for cleaning up event handlers when template is destroyed