Tests cleanup, refactoring