Refactored optimizer tests