impl rewrite.t

Signed-off-by: Akira Hayakawa <ruby.wktk@gmail.com>
refactoring..

Signed-off-by: Akira Hayakawa <ruby.wktk@gmail.com>