fixes and refactoring a bit
publish
fix tests