Fix test for optimize method