minor refactoring, a couple issues fixed
first tests