Fixed password generation lockup. Added tests.