fixing bug in api call and tests