ACT-1418 Unit tests and suggested fix for NPE on uncaught error event

Work done at Hackergarten Vienna together with @rafacm and
@florianpirchner
Merge branch 'ACT-1418' of https://github.com/pebrc/Activiti into pebrc-ACT-1418
Merge branch 'master' of github.com:Activiti/Activiti