Add tests for retrieves and queries
Fix bugs in timing expressions and identifier resolution in queries.