fix optimized case keyword mode bug, add test