closes #369 - in detach() methods, check environment