Fix issue 597 -- entity manager is properly removed even if close operation fails + unit test.
Fix issue 597 -- JUnit 3 style
Fix issue 597 -- Adds copyright header.
Merge pull request #820 from lindenbaum/master

Fix issue 597 -- entity manager is properly removed even if close operation fails + unit test.