Fix attach issue
Improve detach unit tests
Merge pull request #1948 from dotcloud/fix_attach

Fix attach issue