Add connection test to plugin initialization
Refactor handling of query type, add test case for reused prepared statements