functional and unit tests
After Vitaly's review