Refactor 'union' operation and  adding test suite for it