Update code so it is more testable.