Query: improve documentation, allow query parameter to be optional, add test