Restore the correct domain before calling the user callback

This should fix #182. Don't hesitate to ask for corrections. I tried to make it simple.