Implemented removing attachments when documents are removed.
Wrote the unit test for it.
Fixed some bugs as I noticed them.