Implement the listen method and its tests