Bug 23204: Move code in a unit tested sub