Setup testing infrastructure
Added comments in the code previous to some serious refactoring and testing