Better cleanup after detach.
Extracted namespace creation in a method add_namespace to match remote_namespace.
All existing tests pass.