Add cast tests

Related to #817