In reply to NiLu:
A lot of other additions would have also made things simpler. You do have to remember that SystemVerilog isn’t a general purpose programming language. For a lot of people’s needs it’s enough. You might be better off writing some parts of your testbench in C++.