test main with controlled input and output