started refactoring and unit testing lib files