implemented most requirements and added tests
corrected detach()