Move type test after coercion to allow unboxing.
Add test for the scenario.