Handlers for closed Realms are now properly removed

Also added checks for ImplicitTransactions being closed, which is the error that will happen if we didn't remove the handlers. Unit tests has been added for both cases.

@emanuelez @kneth @bmunkholm 
Should we do `try...finally` in unit tests to be sure we don't leak?