add test case to #flatten
fix typo
Refactor #flatten_merge

Not to unnecessary recursive search.
implement #classify