Modified ping_test method to handle lost packets while pinging.