Add various test tools
Fix possible leaks