--- ./tests/scripts/common.sh_orig	2023-04-24 08:02:00.326506213 +0000
+++ ./tests/scripts/common.sh	2023-04-24 08:05:13.232468220 +0000
@@ -71,7 +71,7 @@
 	local PORT=$1
 	reserve_port $PORT
 	have_port_finder
-	if ! $PFCMD -an|grep "[\:\.]$PORT" >/dev/null 2>&1; then
+	if ! $PFCMD -an|grep LISTEN|grep "[\:\.]$PORT" >/dev/null 2>&1; then
 		return 1
 	fi
 	unreserve_port $PORT
@@ -80,7 +80,7 @@
 check_if_port_listening() {
 	local PORT=$1
 	have_port_finder
-	$PFCMD -anl|grep "[\:\.]$PORT"|grep LISTEN >/dev/null 2>&1
+	$PFCMD -anl|grep LISTEN|grep "[\:\.]$PORT"|grep LISTEN >/dev/null 2>&1	
 }
 
 # Find a port number not currently in use.
