improve handling of old passwords

added test for scrambleOldPassword
rewrote scrambleOldPassword and move related code to be all in one function