refactoring before statment in tests
refactoring specs
handling exceptions, writing output to html, general refactoring