[MIN] XQuery: fixes #1023 (minor rewritings, test added)