Refactored code in Linear Regression and correspondingly modified the tests