fixed comparison logic to support null values properly
- added test to detect reoccurences of bad optimizations