refine and fix Pipe
add more tests for Pipe