Rewrite test logic with clocks