Thanks for the note--that's a great point. I just added in random checks for that problem, so they can't just fill in the 3 sample tests each time and get it right. Give it a try!
In general, it's a tricky problem because if the students are really motivated to cheat the system, they can find a way -- for example, because if integer overflowing, there is a maximum number that will work with factorial in java before it breaks down, so they'd just need to add in a bunch more if statements like the ones you mentioned to cheat it, but it would at least be significantly more difficult to do.
I hope this helps you, and please don't hesitate to reach out with any other problems you think could have improved autograders, and we'd be happy to take a look. We're always trying to improve the courses and graders so they're more helpful to teachers.