re factored constructor. updated test cases