Add sparql query test and fix query implementation.