Rewrote tests to dynamically generate test user and pasword history and
added middleware tests.