Use tree chain instead of pipes + more tests