1. A computer-implemented method for generating a test for a Design-Under-Test (DUT) based on a template, wherein the method is performed by a processor, the method comprising: partitioning the template into at least a first portion and a second portion, wherein the first portion is determined to be executed in speculative execution by the DUT; injecting a branch instruction operative to cause the DUT to perform speculative execution, the branch instruction defines at least a speculative branch leg and a non-speculative branch leg, wherein the DUT is operative to perform speculative execution of the speculative branch leg; generating a first set of instructions based on the first portion of the template, wherein the first set of instructions is placed in the speculative branch leg; and generating a second set of instructions, wherein the second set of instructions is placed in the non-speculative branch leg.