Improve readability of tests.
Extract check if output should be created into utility class, add tests for it and fix its implementation.