WIP: pipeline. Add test for pipeline. Fix race condition.