fix casting code generation and add test all types