Testing complex flag conditions and ensuring complete case coverage