added tests; log restructured; refactoring;