Fixed compare errors.

When values are equal operators: 'operator<', 'operator>', 'operator>=' and
'operator<=' produce incorrect result. Add test test_compare.cpp.