fixed the lint issue
add the mock terminal
Refactor the code to match the oop mode for easy mock and test