Optimizing automated tests