Fix CLI sandbox command DM helper and QueryCommand

In addition to fixing QueryCommand (reported in #801), this fixes a general issue with the sandbox CLI command not setting the DocumentManager helper properly (due to a bug I introduced in a49d20d1906523bc4845c89666bef9f41794f1b1).