fix issue #10 and improved the generation of references (now create a document and not just a mongoid), thanks Ivan