Fix various failing test cases

These changes make current master run all tests successfully against wmde/WikibaseQueryEngine@a689b8a4601f661517f7a090b976fdb6f53c53c0.