fix tests, finish refactoring for better thor layout