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

Work done at Hackergarten Vienna together with @rafacm and
@florianpirchner