Add eunit tests for resource cleanup