refactor pipeTo/dest and add tests