better unit testing + resource cleanup