Bugfix: deallocate_ip_address in-loop deletion

* Refactored deallocate_ip_address such that list traversal was separate
from deleting elements from the list.
* Updated tests.