Prepared statement tests and fixes

Closes #81
Fixes #106 
Fixes #107