Improved test coverage of toQuery and fromQuery functions