Fix the cast from Double type and add test cases for OVERLAY