check casted expressions

Fix for #169, all tests pass