fix another subtle state race
fix unit stderr communication