Refactored code coverage script