refactor output capture tests