Refactor of 'intersection' operation and added test case for the same