ADDED logout code and unit test.