made unit test close conditional writer