Ensure capabilities response contains <query> node before trying to use it

This fixes issue #29.