Handling resources better with unit tests