Fix for local entity query incorrectly inferring a duration when the entity type is known, + tests and EntityQuery refactoring.