Test: various issues with the replication-4.tcl test fixed.

The test actually worked, but vars for master and slave were inverted
and sometimes used incorrectly.