Add tests with optimization