added basic testing support
refactoring and adding tests