Added new tests and production code to close prepared statement and connection objects properly