Reimplemented get_failures

It was not working for the case where there is a
faiure directory with no keys.

I also reimplemented it to reduce code count
and wrote tests.