fix + tests for issue #12

fix + tests for issue #12, handled with try/finally