Moved the database.ini original config replacement to after the agent queries

Fixes current acceptance test failure.