Fix bugs caused by previous commit

Previously raised exception if compared to object of different type rather than fail.