Fix a bug with gcache causing invalid directory listings after file
updates.  Also added unittest for listdir which spotted the bug.