Fixed comparison type check.
Added tests for typecheck.