Fixed a bug in port mapping test cleanup function.

Review: https://reviews.apache.org/r/23955