Fix for #31, incorrect error on prepare failure.
Merge fix for #31 from jghallagher.