Solving problem with internal classes

This is my fix, first commit will introduce a test to reproduce the error, the second one will be the fix for it.

Related to #59
If the only code who can mess with error handlers would be in this class, then this solution would fit. However in case if a test wants to set it's own sub-error handler and forget to do a restore, then this restore wouldn't set proper error handler back.

I suggest:

1. store what `set_error_handler` returns
2. if it turns out to be valid error handler, then set it back here