Fixed entity manager usage in test.