Some test fixes and refactoring
Merge pull request #1 from sergeyklay/next

Some test fixes and refactoring