add invalidation functionality to Store->addMultipleStmts

+ test
make QueryCache functions more robust

problem is, that in some scenarios parts of the query
container are already empty or not set, so some foreach-
loops running into errors. so check the variable before
passing them through the loop