Fix detach cascading see #978 


As described in #978 I think the detach cascading for embedded documents is not working correct. I also added  a small test.

I was not sure where to put the test.. I hope it is correct this way.