started some basic testing and more code refactoring