password recovery fix and tests