Add API test for api.programs, optimize.