Fix get_addresses_by and add tests.