improve handling of old passwords

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