Adding _.getQuery() and corresponding tests

Same pull request as the one from master.