fix bugs in regtest procedure