Refactored line construction and fixed up tests