Test harness for PersistentStore.QueryBuilder

Makes QueryBuilder SQL directly testable.

Refactored PersistentStoreTest to an abstract base class PersistentStoreBaseTest so the query builder tests can reuse the same database setup.