simplify integer casting
move test and driver code out of src