Large rewrite of the query code

Still very incomplete, but queries like [?a desires ?b, ?b type Action] can now be
processed.
Added many tests

Several (the one which are still expected to fail) are disabled.
The enabled one are expected to pass all.