diff --git a/tests/test-archive b/tests/test-archive
--- a/tests/test-archive
+++ b/tests/test-archive
@@ -18,8 +18,7 @@ echo "name = test-archive" >> .hg/hgrc
 echo "allowzip = true" >> .hg/hgrc
 echo "allowgz = true" >> .hg/hgrc
 echo "allowbz2 = true" >> .hg/hgrc
-serverpid=`mktemp`
-hg serve -p 20059 -d --pid-file=$serverpid
+hg serve -p 20059 -d --pid-file=hg.pid
 
 TIP=`hg id -v | cut -f1 -d' '`
 QTIP=`hg id -q`
@@ -35,5 +34,4 @@ http_proxy= python getarchive.py "$TIP" 
 http_proxy= python getarchive.py "$TIP" zip > archive.zip
 unzip -t archive.zip | sed "s/$QTIP/TIP/"
 
-kill `cat $serverpid`
-rm $serverpid
+kill `cat hg.pid`
diff --git a/tests/test-pull b/tests/test-pull
--- a/tests/test-pull
+++ b/tests/test-pull
@@ -7,8 +7,7 @@ hg init
 hg addremove
 hg commit -m 1
 hg verify
-serverpid=`mktemp`
-hg serve -p 20059 -d --pid-file=$serverpid
+hg serve -p 20059 -d --pid-file=hg.pid
 cd ..
 
 hg clone http://localhost:20059/ copy
@@ -19,5 +18,4 @@ cat foo
 hg manifest
 hg pull
 
-kill `cat $serverpid`
-rm $serverpid
+kill `cat ../test/hg.pid`