Fixed pipeline implementation and added unit tests