check casted expressions

Fix for #168, all tests pass