fix: properly remove event listeners for memory leak prevention

This PR is just to show buggy code, and possible fix related to https://github.com/angular/angular.js/issues/5270
The final code should be at least re-factored a bit and correspondent tests should be added.
I'll not be able to do right PR for now...