refactoring, and add test code about stdin pipe implementent

Signed-off-by: Kouhei Maeda <mkouhei@palmtb.net>