optimize is_test judgement