example snippets converting problematic code to be more testable