refactored some files and improved test framework