I managed to reproduce this behavior myself but unfortunately I don't know how to fix it. I think a better place to ask this question is on the MarkLogic list (general@developer.marklogic.com) because the people there have more experience with MarkLogic. If you get an answer it might be good to post it here as well to help those that bump into it in the future.