Bug 19936: Move and add tests for Generate_Userid