Add backwards compatible passwords tests and fix infinite loop bug