Promise.race() based select like pipeTo implementation

Also adds more test cases for pipeTo