Fix and add tests for empty_base_optimization.