HTML5-mode compatibility + tests, fixes #276
 - Refactoring directive test event handling