I was looking back at a case where a customer that had written an OTA script to purge some runs and remembered something that may fix you script. We could never the the pruge to run using a variable for the DateUnit parameter.
You might be able to declair a constant and use that such as
Const daysPerUnit = 1
When I worked with the customer we just added the actual value instead of a variable and the script run. So your actual purge line would look like this...
'This will send the call to actually purge the old test runs.
tdc.PurgeRuns tsFilter.Text, keepLastNumberOfRuns, 1, purgeRunsOlderThanThisManyDays, purgeStepsOnly
This might be the problem.