Factor out the username munging functions and add specs.