Refactoring delete functions, test and pylint improvements