Allow running without optimizer, refactor test code