refactor(fo_match): use scoped_map
refactor(rewrite): use scoped_map as a type of substitution
test(fo_match): add more tests, 100% coverage