Continue refactoring; started tests