Wrap model test in try/finally

Before if the test crashed in the middle we would have leaked the
prototype changes. Now we make sure we clean up in a finally block.