Yury: resolved conflicts and problems with libs, also added tests.