Add unit test.
Fix more bugs.
more utest.
update dir entry extraction algorithm.