Fixed covariant cast problem (#443).

Simplified #353 test, as it is not hides by #443 anymore.