add check for null in Query Equals, dictionary usage fixes

Couple unit tests fail because Query Equals does not check for null values before trying to check type. Also found a few spots where ContainsKey should have been used instead of dict[key] == null.