CORE-2002: added unit tests and fixes
Merge pull request #299 from valentinomiazzo/CORE-2002

CORE-2002: added unit tests and fixes