Corected the logic a bit, added a failure test.