Move safe cast example to unit test