Bugs fixes
Unit tests