This is the side effect of lazy teaching. Unique tests cannot be leaked. Problem solved.
Or maybe don't do stupid tests for computer science.
This is a space where whiteboarding is a good idea, in fact, interactive whiteboarding with a whole class is a great way to teach and work through problems.
Any type of interactive test is hard to fake.