On the local machine the connection will be established but on remote machine the error:
definition of service "test4" not found
The service file is read by the client, not the server. So the remote machine will use the service file local to it. Did you copy your pg_service.conf to the proper directory on the remote machine?