Make sure we have a working PDO instance before clearing temp tables

Make sure we have a working PDO instance before clearing temp tables in the tearDown. This PR fixes #302.