Add test before detach and remove.packages.