Fix failing MemoryAccessMonitor tests in case of optimizations