Fix a bug that was skipping the first interval in the OPT calculations.

Add different test intervals to showcase the bug.

Setting `OPT[0] = 0` incorrectly skips the first interval in `OPT