simplified pipe mechanism and added tests