Fixed a regression on #255 and covered another case where files are not properly closed

Hi,

version 0.9.10-SNAPSHOT seems to have a regression on #255 which I fixed with this CR. Additionally, I covered another case where files are left in a locked state upon an unsuccessful attempt to open the db. This one deals with cases where de-serialization fails causing the engine to be successfully created but creating the DB instance fails.

Thanks
Joerg Henne