Update tests to use the new api_{spawn,close} functions