fixed buggy test, exposed some query internals so scwala can use them, improved printing