a few fixes+ test coverage for the detach mode