Adding System test and refactor (Functional programming)