Some refactor

Put some common functionality to a common module.
And new exercise on FoldDir can reuse the new common module.