diff --git a/examples/create_public_key.py b/examples/create_public_key.py
index 8c088a651f7155b3422abe9315785e96e1e6c21b..cd4345b7bf41d78248f3e9901fbe798c38df8e92 100644
--- a/examples/create_public_key.py
+++ b/examples/create_public_key.py
@@ -20,7 +20,8 @@ from duniterpy.key import SigningKey
 
 ################################################
 
-if __name__ == "__main__":
+
+def create_public_key():
     # prompt hidden user entry
     salt = getpass.getpass("Enter your passphrase (salt): ")
 
@@ -32,3 +33,7 @@ if __name__ == "__main__":
 
     # Display your public key
     print("Public key for your credentials: %s" % key.pubkey)
+
+
+if __name__ == "__main__":
+    create_public_key()
diff --git a/examples/listen_ws2p.py b/examples/listen_ws2p.py
index 6a8c4f2471252af77e2fcc9f5c6580c259539c5b..ef4d9057ba642d9ecb3d61aa683dde8d9de1c455 100644
--- a/examples/listen_ws2p.py
+++ b/examples/listen_ws2p.py
@@ -16,12 +16,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
 import json
-import sys
 import jsonschema
-from jsonschema import ValidationError
 
 from duniterpy.key import SigningKey
-
 from duniterpy.helpers.ws2p import handshake, generate_ws2p_endpoint
 from duniterpy.api.client import Client
 
@@ -37,7 +34,7 @@ CURRENCY = "g1-test"
 ################################################
 
 
-def main():
+def listen_ws2p():
     """
     Main code
     """
@@ -75,10 +72,10 @@ def main():
             # Resolve handshake
             print("Handshake...")
             handshake(ws, signing_key, CURRENCY)
-        except ValidationError as exception:
+        except jsonschema.ValidationError as exception:
             print(exception.message)
             print("HANDSHAKE FAILED !")
-            sys.exit(1)
+            return
 
         print("Handshake ok")
 
@@ -101,4 +98,4 @@ def main():
 
 
 if __name__ == "__main__":
-    main()
+    listen_ws2p()
diff --git a/examples/load_binary_encrypted_message.py b/examples/load_binary_encrypted_message.py
index 19447c271b407bfc99b2e20f69c27d1f6757465f..3d1e9ab0151adaeaf65cdecdda2ffeea409115c0 100644
--- a/examples/load_binary_encrypted_message.py
+++ b/examples/load_binary_encrypted_message.py
@@ -20,18 +20,15 @@ import sys
 
 from duniterpy.key import SigningKey
 
-if __name__ == "__main__":
 
-    if len(sys.argv) < 2:
-        print(
-            """
-        Usage:
-            python decrypt_message.py ENCRYPTED_MESSAGE_FILEPATH
-        """
-        )
+def load_binary_encrypted_message(signed_message_path=None):
+    if not signed_message_path:
+        if len(sys.argv) < 2:
+            print("Usage: python decrypt_message.py ENCRYPTED_MESSAGE_FILEPATH")
+            return
 
-    # capture encrypted message filepath argument
-    signed_message_path = sys.argv[1]
+        # capture encrypted message filepath argument
+        signed_message_path = sys.argv[1]
 
     # prompt hidden user entry
     salt = getpass.getpass("Enter your passphrase (salt): ")
@@ -54,3 +51,7 @@ if __name__ == "__main__":
         message = str(error)
 
     print(message)
+
+
+if __name__ == "__main__":
+    load_binary_encrypted_message()
diff --git a/examples/load_binary_signed_message.py b/examples/load_binary_signed_message.py
index 57cea48d5076dbbe2700329249c5dd0453443519..7d58e905864ef2f33075a3938a8a354690023ea4 100644
--- a/examples/load_binary_signed_message.py
+++ b/examples/load_binary_signed_message.py
@@ -19,18 +19,15 @@ import sys
 
 from duniterpy.key import VerifyingKey
 
-if __name__ == "__main__":
 
-    if len(sys.argv) < 2:
-        print(
-            """
-        Usage:
-            python verify_signed_message.py SIGNED_MESSAGE_FILEPATH
-        """
-        )
+def load_binary_signed_message(signed_message_path=None):
+    if not signed_message_path:
+        if len(sys.argv) < 2:
+            print("Usage: python verify_signed_message.py SIGNED_MESSAGE_FILEPATH")
+            return
 
-    # capture signed message filepath argument
-    signed_message_path = sys.argv[1]
+        # capture signed message filepath argument
+        signed_message_path = sys.argv[1]
 
     # ask public key of the signer
     pubkeyBase58 = input("Enter public key of the message issuer: ")
@@ -48,3 +45,7 @@ if __name__ == "__main__":
         message = str(error)
 
     print(message)
+
+
+if __name__ == "__main__":
+    load_binary_signed_message()
diff --git a/examples/load_cleartext_ascii_armor_message.py b/examples/load_cleartext_ascii_armor_message.py
index 339f24ee5823a3c72ec47fedfd1d43086e5ce299..4952c340e9c505dcd0c294000af1ec07e084fb5a 100644
--- a/examples/load_cleartext_ascii_armor_message.py
+++ b/examples/load_cleartext_ascii_armor_message.py
@@ -23,7 +23,8 @@ CLEARTEXT_AA_MESSAGE_PATH = "/tmp/duniter_cleartext_aa_message.txt"
 
 ################################################
 
-if __name__ == "__main__":
+
+def load_cleartext_ascii_armor_message():
     # Ask public key of the issuer
     pubkeyBase58 = input("Enter public key of the message issuer: ")
 
@@ -44,3 +45,7 @@ if __name__ == "__main__":
         + "----------------------------------"
     )
     print(result)
+
+
+if __name__ == "__main__":
+    load_cleartext_ascii_armor_message()
diff --git a/examples/load_credentials_file.py b/examples/load_credentials_file.py
index 9942a1e9db51ef5542acae24153d141b75965dbb..903b499ef45b2f123bd1493a2720746769bd428e 100644
--- a/examples/load_credentials_file.py
+++ b/examples/load_credentials_file.py
@@ -19,13 +19,15 @@ import sys
 
 from duniterpy.key import SigningKey
 
-if __name__ == "__main__":
-    if len(sys.argv) < 2:
-        print("Usage: python load_credentials_file.py FILEPATH")
-        sys.exit(1)
 
-    # capture filepath argument
-    credentials_filepath = sys.argv[1]
+def load_credentials_file(signing_key_instance=None):
+    if not signing_key_instance:
+        if len(sys.argv) < 2:
+            print("Usage: python load_credentials_file.py FILEPATH")
+            return
+
+        # capture filepath argument
+        credentials_filepath = sys.argv[1]
 
     # create SigningKey instance from file
     signing_key_instance = SigningKey.from_credentials_file(
@@ -34,3 +36,7 @@ if __name__ == "__main__":
 
     # print pubkey
     print("Public key from credentials file: {}".format(signing_key_instance.pubkey))
+
+
+if __name__ == "__main__":
+    load_credentials_file()
diff --git a/examples/load_encrypted_ascii_armor_message.py b/examples/load_encrypted_ascii_armor_message.py
index 5e27efb185b1bc460e6ed2980f9e942a583c38ba..7c3600b4b2eb3be56ec222af7e7e373f30322c14 100644
--- a/examples/load_encrypted_ascii_armor_message.py
+++ b/examples/load_encrypted_ascii_armor_message.py
@@ -25,7 +25,8 @@ ENCRYPTED_AA_MESSAGE_PATH = "/tmp/duniter_aa_encrypted_message.txt"
 
 ################################################
 
-if __name__ == "__main__":
+
+def load_encrypted_ascii_armor_message():
     # Ask public key of the recipient
     pubkeyBase58 = input("Enter public key of the message issuer: ")
 
@@ -49,3 +50,7 @@ if __name__ == "__main__":
     )
 
     print(AsciiArmor.parse(ascii_armor_block, signing_key, [pubkeyBase58]))
+
+
+if __name__ == "__main__":
+    load_encrypted_ascii_armor_message()
diff --git a/examples/load_local_blockchain.py b/examples/load_local_blockchain.py
index b5d727c4a9be99621cd5e5dd322331f3b0ef30a5..212f72e8de14d905840e87b086743d6359a9b39a 100644
--- a/examples/load_local_blockchain.py
+++ b/examples/load_local_blockchain.py
@@ -21,10 +21,16 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from duniterpy.helpers.blockchain import load
 
-bc = load()  # gets blockchain iterator
-b = next(bc)  # gets block
-print(f"first block number is: {b.number}")  # should return 0
-# you can access all properties of this block through it's duniterpy objects attributes
-print(f"second block number is: {next(bc).number}")  # should return 1
-print(f"third block number is: {next(bc).number}")  # should return 2
-# (and so on)
+
+def load_local_blockchain():
+    bc = load()  # gets blockchain iterator
+    b = next(bc)  # gets block
+    print(f"first block number is: {b.number}")  # should return 0
+    # you can access all properties of this block through it's duniterpy objects attributes
+    print(f"second block number is: {next(bc).number}")  # should return 1
+    print(f"third block number is: {next(bc).number}")  # should return 2
+    # (and so on)
+
+
+if __name__ == "__main__":
+    load_local_blockchain()
diff --git a/examples/load_scuttlebutt_file.py b/examples/load_scuttlebutt_file.py
index e5e557ccb8f6b204282b145f810858bd74ff1310..46fbf0de64ee30ead01a29fe085c7ce8eaf7df6e 100644
--- a/examples/load_scuttlebutt_file.py
+++ b/examples/load_scuttlebutt_file.py
@@ -19,13 +19,15 @@ import sys
 
 from duniterpy.key import SigningKey
 
-if __name__ == "__main__":
-    if len(sys.argv) < 2:
-        print("Usage: python load_scuttlebutt_file.py FILEPATH")
-        sys.exit(1)
 
-    # capture filepath argument
-    scuttlebutt_filepath = sys.argv[1]
+def load_scuttlebutt_file(signing_key_insance=None):
+    if not signing_key_insance:
+        if len(sys.argv) < 2:
+            print("Usage: python load_scuttlebutt_file.py FILEPATH")
+            return
+
+        # capture filepath argument
+        scuttlebutt_filepath = sys.argv[1]
 
     # create SigningKey instance from file
     signing_key_instance = SigningKey.from_ssb_file(
@@ -34,3 +36,7 @@ if __name__ == "__main__":
 
     # print pubkey
     print("Public key from scuttlebutt file: {}".format(signing_key_instance.pubkey))
+
+
+if __name__ == "__main__":
+    load_scuttlebutt_file()
diff --git a/examples/request_available_nodes.py b/examples/request_available_nodes.py
index e4a394bd7e2ea350dc7f393297678c75e37db261..7b806d002c6646da2ecc520a645be2a5e9c905a4 100644
--- a/examples/request_available_nodes.py
+++ b/examples/request_available_nodes.py
@@ -29,7 +29,7 @@ BMAS_ENDPOINT = "BMAS g1-test.duniter.org 443"
 ################################################
 
 
-def main():
+def request_available_nodes():
     """
     Main code
     """
@@ -49,4 +49,4 @@ def main():
 
 
 if __name__ == "__main__":
-    main()
+    request_available_nodes()
diff --git a/examples/request_data.py b/examples/request_data.py
index f86b7a4552ed5aa2c680084a14dc348295757a50..caea39bfda3558558889cd2f45ccdefbb09abcf4 100644
--- a/examples/request_data.py
+++ b/examples/request_data.py
@@ -29,7 +29,7 @@ BMAS_ENDPOINT = "BMAS g1-test.duniter.org 443"
 ################################################
 
 
-def main():
+def request_data():
     """
     Main code (synchronous requests)
     """
@@ -80,4 +80,4 @@ def main():
 
 
 if __name__ == "__main__":
-    main()
+    request_data()
diff --git a/examples/request_data_async.py b/examples/request_data_async.py
index 0939f0393d24ae0093a94322b394474ff4d42b34..1633ca1a227dbce2cb42b0abf8ee98a046e79159 100644
--- a/examples/request_data_async.py
+++ b/examples/request_data_async.py
@@ -39,7 +39,7 @@ async def coroutine(function, *args, **kwargs):
     return function(*args, **kwargs)
 
 
-async def main():
+async def request_data_async():
     """
     Main code (asynchronous requests)
 
@@ -72,4 +72,5 @@ async def main():
 
 # Latest duniter-python-api is asynchronous and you have to use asyncio, an asyncio loop and a "as" on the data.
 # ( https://docs.python.org/3/library/asyncio.html )
-asyncio.get_event_loop().run_until_complete(main())
+if __name__ == "__main__":
+    asyncio.get_event_loop().run_until_complete(request_data_async())
diff --git a/examples/request_data_elasticsearch.py b/examples/request_data_elasticsearch.py
index 3e247d7a66ce52eb2ca207f20956b92e011146a7..543d8e8bab4702c1dbcdcb5e173dca92b516cdcf 100644
--- a/examples/request_data_elasticsearch.py
+++ b/examples/request_data_elasticsearch.py
@@ -32,7 +32,7 @@ ES_USER_ENDPOINT = "ES_USER_API g1-test.data.duniter.fr 443"
 ################################################
 
 
-def main():
+def request_data_elasticsearch():
     """
     Main code (synchronous requests)
     """
@@ -64,4 +64,4 @@ def main():
 
 
 if __name__ == "__main__":
-    main()
+    request_data_elasticsearch()
diff --git a/examples/request_data_graphql.py b/examples/request_data_graphql.py
index e9fa5f1fd7e670a84da7db32696f1a29262cd090..b486addac08792f86fbfd61a4dcd0b54cb5a9c11 100644
--- a/examples/request_data_graphql.py
+++ b/examples/request_data_graphql.py
@@ -1,4 +1,3 @@
-import sys
 import json
 
 from duniterpy.api.client import Client
@@ -16,7 +15,7 @@ GVA_ENDPOINT = "GVA S g1.librelois.fr 443 gva"
 ################################################
 
 
-def main():
+def request_data_graphql():
     client = Client(GVA_ENDPOINT)
 
     # get query to get schema from api
@@ -39,13 +38,13 @@ def main():
         ast_document = language.parse(query)
     except GraphQLSyntaxError as exception:
         print(f"Query syntax error: {exception.message}")
-        sys.exit(1)
+        return
 
     # validate query against schema
     errors = validate(schema, ast_document)
     if errors:
         print(f"Schema errors: {errors}")
-        sys.exit(1)
+        return
 
     # send valid query to api
     response = client.query(query)
@@ -56,4 +55,4 @@ def main():
 
 
 if __name__ == "__main__":
-    main()
+    request_data_graphql()
diff --git a/examples/request_web_socket_block.py b/examples/request_web_socket_block.py
index d52aba94096659fb8a0756475bdbc5747409e1bc..16583c367c7c19e27bbca2ca31044a40e391e6a1 100644
--- a/examples/request_web_socket_block.py
+++ b/examples/request_web_socket_block.py
@@ -33,7 +33,7 @@ BMAS_ENDPOINT = "BMAS g1-test.duniter.org 443"
 ################################################
 
 
-def main():
+def request_web_socket_block():
     """
     Main code
     """
@@ -61,4 +61,4 @@ def main():
 
 
 if __name__ == "__main__":
-    main()
+    request_web_socket_block()
diff --git a/examples/request_ws2p.py b/examples/request_ws2p.py
index 73c441b061fff73811240e64fb594643852cea9c..858f73642699e290e6fc84d42b97019bd67c7f9e 100644
--- a/examples/request_ws2p.py
+++ b/examples/request_ws2p.py
@@ -17,7 +17,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import json
 import time
-import sys
 
 import jsonschema
 from jsonschema import ValidationError
@@ -79,7 +78,7 @@ def send(ws: WSConnection, request: str, request_id: str, schema: dict) -> Any:
     return response
 
 
-def main():
+def request_ws2p():
     """
     Main code
     """
@@ -118,7 +117,7 @@ def main():
         except ValidationError as exception:
             print(exception.message)
             print("HANDSHAKE FAILED !")
-            sys.exit(1)
+            return
 
         # Send ws2p request
         print("Send getCurrent() request")
@@ -169,4 +168,4 @@ def main():
 
 
 if __name__ == "__main__":
-    main()
+    request_ws2p()
diff --git a/examples/save_and_load_private_key_file.py b/examples/save_and_load_private_key_file.py
index 8e3c477f8ea30950302e14577dca39d633ede48f..5bd4da9e317e78b1f6e632e6309e9f7d6446216c 100644
--- a/examples/save_and_load_private_key_file.py
+++ b/examples/save_and_load_private_key_file.py
@@ -18,7 +18,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 from duniterpy.key import SigningKey
 import getpass
 import os
-import sys
 
 if "XDG_CONFIG_HOME" in os.environ:
     home_path = os.environ["XDG_CONFIG_HOME"]
@@ -38,33 +37,44 @@ PRIVATE_KEYS_FILE_PATH = os.path.join(home_path, ".duniter_account_private_keys.
 
 ################################################
 
-# prompt hidden user entry
-salt = getpass.getpass("Enter your passphrase (salt): ")
 
-# prompt hidden user entry
-password = getpass.getpass("Enter your password: ")
+def save_and_load_private_key_file():
+    # prompt hidden user entry
+    salt = getpass.getpass("Enter your passphrase (salt): ")
 
-# prompt public key
-pubkey = input("Enter your public key: ")
+    # prompt hidden user entry
+    password = getpass.getpass("Enter your password: ")
 
-# init signer instance
-signer = SigningKey.from_credentials(salt, password)
+    # prompt public key
+    pubkey = input("Enter your public key: ")
 
-# check public key
-if signer.pubkey != pubkey:
-    print("Bad credentials!")
-    sys.exit(1)
+    # init signer instance
+    signer = SigningKey.from_credentials(salt, password)
 
-# save private keys in a file (json format)
-signer.save_private_key(PRIVATE_KEYS_FILE_PATH)
+    # check public key
+    if signer.pubkey != pubkey:
+        print("Bad credentials!")
+        return
 
-# document saved
-print("Private keys for public key %s saved in %s" % (pubkey, PRIVATE_KEYS_FILE_PATH))
+    # save private keys in a file (json format)
+    signer.save_private_key(PRIVATE_KEYS_FILE_PATH)
 
-# load private keys from file
-loaded_signer = SigningKey.from_private_key(PRIVATE_KEYS_FILE_PATH)  # type: SigningKey
+    # document saved
+    print(
+        "Private keys for public key %s saved in %s" % (pubkey, PRIVATE_KEYS_FILE_PATH)
+    )
 
-# check public key from file
-print("Public key %s loaded from file %s" % (pubkey, PRIVATE_KEYS_FILE_PATH))
+    # load private keys from file
+    loaded_signer = SigningKey.from_private_key(
+        PRIVATE_KEYS_FILE_PATH
+    )  # type: SigningKey
 
-sys.exit(0)
+    # check public key from file
+    print(
+        "Public key %s loaded from file %s"
+        % (loaded_signer.pubkey, PRIVATE_KEYS_FILE_PATH)
+    )
+
+
+if __name__ == "__main__":
+    save_and_load_private_key_file()
diff --git a/examples/save_and_load_private_key_file_ewif.py b/examples/save_and_load_private_key_file_ewif.py
index 135ed2026eae2708f6f13ec16db6b773c0721745..9a11e39e20d5aa5e633f38e053a3200cbbf8cf22 100644
--- a/examples/save_and_load_private_key_file_ewif.py
+++ b/examples/save_and_load_private_key_file_ewif.py
@@ -18,7 +18,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 from duniterpy.key import SigningKey
 import getpass
 import os
-import sys
 
 if "XDG_CONFIG_HOME" in os.environ:
     home_path = os.environ["XDG_CONFIG_HOME"]
@@ -38,49 +37,53 @@ PRIVATE_KEY_FILE_PATH = os.path.join(home_path, ".duniter_account_ewif_v1.dunite
 
 ################################################
 
-# prompt hidden user entry
-salt = getpass.getpass("Enter your passphrase (salt): ")
 
-# prompt hidden user entry
-password = getpass.getpass("Enter your password: ")
+def save_and_load_private_key_file_ewif():
+    # prompt hidden user entry
+    salt = getpass.getpass("Enter your passphrase (salt): ")
 
-# prompt public key
-pubkey = input("Enter your public key: ")
+    # prompt hidden user entry
+    password = getpass.getpass("Enter your password: ")
 
-# init signer instance
-signer = SigningKey.from_credentials(salt, password)
+    # prompt public key
+    pubkey = input("Enter your public key: ")
 
-# check public key
-if signer.pubkey != pubkey:
-    print("Bad credentials!")
-    sys.exit(1)
+    # init signer instance
+    signer = SigningKey.from_credentials(salt, password)
 
-# prompt hidden user entry
-ewif_password = getpass.getpass("Enter an encryption password: ")
+    # check public key
+    if signer.pubkey != pubkey:
+        print("Bad credentials!")
+        return
 
-# save private key in a file (EWIF v1 format)
-signer.save_ewif_file(PRIVATE_KEY_FILE_PATH, ewif_password)
+    # prompt hidden user entry
+    ewif_password = getpass.getpass("Enter an encryption password: ")
 
-# document saved
-print(
-    "Private key for public key %s saved in %s" % (signer.pubkey, PRIVATE_KEY_FILE_PATH)
-)
+    # save private key in a file (EWIF v1 format)
+    signer.save_ewif_file(PRIVATE_KEY_FILE_PATH, ewif_password)
 
-try:
-    # load private keys from file
-    loaded_signer = SigningKey.from_ewif_file(
-        PRIVATE_KEY_FILE_PATH, ewif_password
-    )  # type: SigningKey
-
-    # check public key from file
+    # document saved
     print(
-        "Public key %s loaded from file %s"
-        % (loaded_signer.pubkey, PRIVATE_KEY_FILE_PATH)
+        "Private key for public key %s saved in %s"
+        % (signer.pubkey, PRIVATE_KEY_FILE_PATH)
     )
 
-except IOError as error:
-    print(error)
-    sys.exit(1)
+    try:
+        # load private keys from file
+        loaded_signer = SigningKey.from_ewif_file(
+            PRIVATE_KEY_FILE_PATH, ewif_password
+        )  # type: SigningKey
+
+        # check public key from file
+        print(
+            "Public key %s loaded from file %s"
+            % (loaded_signer.pubkey, PRIVATE_KEY_FILE_PATH)
+        )
+
+    except IOError as error:
+        print(error)
+        return
 
 
-sys.exit(0)
+if __name__ == "__main__":
+    save_and_load_private_key_file_ewif()
diff --git a/examples/save_and_load_private_key_file_pubsec.py b/examples/save_and_load_private_key_file_pubsec.py
index afe41a370ed61c0f56d1738e00df366fed0311c1..2f44dcf6c039470bc68131dee64a13570b7e2134 100644
--- a/examples/save_and_load_private_key_file_pubsec.py
+++ b/examples/save_and_load_private_key_file_pubsec.py
@@ -18,7 +18,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 from duniterpy.key import SigningKey
 import getpass
 import os
-import sys
 
 if "XDG_CONFIG_HOME" in os.environ:
     home_path = os.environ["XDG_CONFIG_HOME"]
@@ -38,44 +37,48 @@ PRIVATE_KEY_FILE_PATH = os.path.join(home_path, ".duniter_account_pubsec_v1.duni
 
 ################################################
 
-# prompt hidden user entry
-salt = getpass.getpass("Enter your passphrase (salt): ")
 
-# prompt hidden user entry
-password = getpass.getpass("Enter your password: ")
+def save_and_load_private_key_file_pubsec():
+    # prompt hidden user entry
+    salt = getpass.getpass("Enter your passphrase (salt): ")
 
-# prompt public key
-pubkey = input("Enter your public key: ")
+    # prompt hidden user entry
+    password = getpass.getpass("Enter your password: ")
 
-# init signer instance
-signer = SigningKey.from_credentials(salt, password)
+    # prompt public key
+    pubkey = input("Enter your public key: ")
 
-# check public key
-if signer.pubkey != pubkey:
-    print("Bad credentials!")
-    sys.exit(1)
+    # init signer instance
+    signer = SigningKey.from_credentials(salt, password)
 
-# save private key in a file (PubSec v1 format)
-signer.save_pubsec_file(PRIVATE_KEY_FILE_PATH)
+    # check public key
+    if signer.pubkey != pubkey:
+        print("Bad credentials!")
+        return
 
-# document saved
-print(
-    "Private key for public key %s saved in %s" % (signer.pubkey, PRIVATE_KEY_FILE_PATH)
-)
+    # save private key in a file (PubSec v1 format)
+    signer.save_pubsec_file(PRIVATE_KEY_FILE_PATH)
 
-try:
-    # load private keys from file
-    loaded_signer = SigningKey.from_pubsec_file(PRIVATE_KEY_FILE_PATH)
-
-    # check public key from file
+    # document saved
     print(
-        "Public key %s loaded from file %s"
-        % (loaded_signer.pubkey, PRIVATE_KEY_FILE_PATH)
+        "Private key for public key %s saved in %s"
+        % (signer.pubkey, PRIVATE_KEY_FILE_PATH)
     )
 
-except IOError as error:
-    print(error)
-    sys.exit(1)
+    try:
+        # load private keys from file
+        loaded_signer = SigningKey.from_pubsec_file(PRIVATE_KEY_FILE_PATH)
+
+        # check public key from file
+        print(
+            "Public key %s loaded from file %s"
+            % (loaded_signer.pubkey, PRIVATE_KEY_FILE_PATH)
+        )
+
+    except IOError as error:
+        print(error)
+        return
 
 
-sys.exit(0)
+if __name__ == "__main__":
+    save_and_load_private_key_file_pubsec()
diff --git a/examples/save_and_load_private_key_file_wif.py b/examples/save_and_load_private_key_file_wif.py
index fd78982dd24dff71ba576827877d12769bdc711c..9c76cbd56601ae93b596bed2e916aa223d6205f0 100644
--- a/examples/save_and_load_private_key_file_wif.py
+++ b/examples/save_and_load_private_key_file_wif.py
@@ -18,7 +18,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 from duniterpy.key import SigningKey
 import getpass
 import os
-import sys
 
 if "XDG_CONFIG_HOME" in os.environ:
     home_path = os.environ["XDG_CONFIG_HOME"]
@@ -38,44 +37,50 @@ PRIVATE_KEY_FILE_PATH = os.path.join(home_path, ".duniter_account_wif_v1.duniter
 
 ################################################
 
-# prompt hidden user entry
-salt = getpass.getpass("Enter your passphrase (salt): ")
 
-# prompt hidden user entry
-password = getpass.getpass("Enter your password: ")
+def save_and_load_private_key_file_wif():
+    # prompt hidden user entry
+    salt = getpass.getpass("Enter your passphrase (salt): ")
 
-# prompt public key
-pubkey = input("Enter your public key: ")
+    # prompt hidden user entry
+    password = getpass.getpass("Enter your password: ")
 
-# init signer instance
-signer = SigningKey.from_credentials(salt, password)
+    # prompt public key
+    pubkey = input("Enter your public key: ")
 
-# check public key
-if signer.pubkey != pubkey:
-    print("Bad credentials!")
-    sys.exit(1)
+    # init signer instance
+    signer = SigningKey.from_credentials(salt, password)
 
-# save private key in a file (WIF v1 format)
-signer.save_wif_file(PRIVATE_KEY_FILE_PATH)
+    # check public key
+    if signer.pubkey != pubkey:
+        print("Bad credentials!")
+        return
 
-# document saved
-print(
-    "Private key for public key %s saved in %s" % (signer.pubkey, PRIVATE_KEY_FILE_PATH)
-)
+    # save private key in a file (WIF v1 format)
+    signer.save_wif_file(PRIVATE_KEY_FILE_PATH)
 
-try:
-    # load private keys from file
-    loaded_signer = SigningKey.from_wif_file(PRIVATE_KEY_FILE_PATH)  # type: SigningKey
-
-    # check public key from file
+    # document saved
     print(
-        "Public key %s loaded from file %s"
-        % (loaded_signer.pubkey, PRIVATE_KEY_FILE_PATH)
+        "Private key for public key %s saved in %s"
+        % (signer.pubkey, PRIVATE_KEY_FILE_PATH)
     )
 
-except IOError as error:
-    print(error)
-    sys.exit(1)
+    try:
+        # load private keys from file
+        loaded_signer = SigningKey.from_wif_file(
+            PRIVATE_KEY_FILE_PATH
+        )  # type: SigningKey
+
+        # check public key from file
+        print(
+            "Public key %s loaded from file %s"
+            % (loaded_signer.pubkey, PRIVATE_KEY_FILE_PATH)
+        )
+
+    except IOError as error:
+        print(error)
+        return
 
 
-sys.exit(0)
+if __name__ == "__main__":
+    save_and_load_private_key_file_wif()
diff --git a/examples/save_binary_encrypted_message.py b/examples/save_binary_encrypted_message.py
index 8000256ee9a703ef78611178003f1c7ef3e18767..50188e5be5dc7e9f9cc15f6de30836bcc393758f 100644
--- a/examples/save_binary_encrypted_message.py
+++ b/examples/save_binary_encrypted_message.py
@@ -23,7 +23,8 @@ ENCRYPTED_MESSAGE_FILENAME = "/tmp/duniter_encrypted_message.bin"
 
 ################################################
 
-if __name__ == "__main__":
+
+def save_binary_encrypted_message():
     # Ask public key of the recipient
     pubkeyBase58 = input("Enter public key of the message recipient: ")
 
@@ -39,3 +40,7 @@ if __name__ == "__main__":
         file_handler.write(encrypted_message)
 
     print("Encrypted message saved in file ./{0}".format(ENCRYPTED_MESSAGE_FILENAME))
+
+
+if __name__ == "__main__":
+    save_binary_encrypted_message()
diff --git a/examples/save_binary_signed_message.py b/examples/save_binary_signed_message.py
index 094d08619ec35e03a1ca08ef4faa6029b3103f12..517c310dbde19e8cedbaba48431873a88309a059 100644
--- a/examples/save_binary_signed_message.py
+++ b/examples/save_binary_signed_message.py
@@ -27,7 +27,8 @@ SIGNED_MESSAGE_FILENAME = "/tmp/duniter_signed_message.bin"
 
 ################################################
 
-if __name__ == "__main__":
+
+def save_binary_signed_message():
     # prompt hidden user entry
     salt = getpass.getpass("Enter your passphrase (salt): ")
 
@@ -50,9 +51,14 @@ if __name__ == "__main__":
     veri = libnacl.sign.Verifier(key.hex_vk())
     # Verify the message!
     verified = veri.verify(signed_message)
+    print(f"Message verified: {verified}")
 
     # save signed message in a file
     with open(SIGNED_MESSAGE_FILENAME, "wb") as file_handler:
         file_handler.write(signed_message)
 
     print("Signed message saved in file ./{0}".format(SIGNED_MESSAGE_FILENAME))
+
+
+if __name__ == "__main__":
+    save_binary_signed_message()
diff --git a/examples/save_cleartext_ascii_armor_message.py b/examples/save_cleartext_ascii_armor_message.py
index 2efb6c2d1ebd5eda862f969a3bca5c3618e7c247..b402edd46f151b8a4e7112786183bbbe6e065dcf 100644
--- a/examples/save_cleartext_ascii_armor_message.py
+++ b/examples/save_cleartext_ascii_armor_message.py
@@ -28,7 +28,8 @@ CLEARTEXT_AA_MESSAGE_PATH = "/tmp/duniter_cleartext_aa_message.txt"
 
 ################################################
 
-if __name__ == "__main__":
+
+def save_cleartext_ascii_armor_message():
     # prompt hidden user entry
     salt = getpass.getpass("Enter your passphrase (salt): ")
 
@@ -59,3 +60,7 @@ if __name__ == "__main__":
             CLEARTEXT_AA_MESSAGE_PATH
         )
     )
+
+
+if __name__ == "__main__":
+    save_cleartext_ascii_armor_message()
diff --git a/examples/save_encrypted_ascii_armor_message.py b/examples/save_encrypted_ascii_armor_message.py
index d5cc6a1b68c1fa488be2b0c6029b064092bf094b..b99be22963131499e44c38b54d3f615f7ce465d0 100644
--- a/examples/save_encrypted_ascii_armor_message.py
+++ b/examples/save_encrypted_ascii_armor_message.py
@@ -26,7 +26,8 @@ ENCRYPTED_AA_MESSAGE_PATH = "/tmp/duniter_aa_encrypted_message.txt"
 
 ################################################
 
-if __name__ == "__main__":
+
+def save_encrypted_ascii_armor_message():
     # Ask public key of the recipient
     pubkeyBase58 = input("Enter public key of the message recipient: ")
 
@@ -63,3 +64,7 @@ if __name__ == "__main__":
             ENCRYPTED_AA_MESSAGE_PATH
         )
     )
+
+
+if __name__ == "__main__":
+    save_encrypted_ascii_armor_message()
diff --git a/examples/save_revoke_document.py b/examples/save_revoke_document.py
index 1496f7d45f6264c4862e2865252e9c103c7bd8ea..4eab17a4bf2e85ea8124420f3558b38b3fb2f5f5 100644
--- a/examples/save_revoke_document.py
+++ b/examples/save_revoke_document.py
@@ -17,7 +17,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import getpass
 import os
-import sys
 from typing import Optional
 
 from duniterpy.api import bma
@@ -114,7 +113,7 @@ def get_signed_raw_revocation_document(
     return revocation.signed_raw()
 
 
-def main():
+def save_revoke_document():
     """
     Main code
     """
@@ -140,7 +139,7 @@ def main():
     # check public key
     if signer.pubkey != pubkey:
         print("Bad credentials!")
-        sys.exit(0)
+        return
 
     # capture current block to get currency name
     current_block = client(bma.blockchain.current)
@@ -150,7 +149,7 @@ def main():
     if identity is None:
         print("Identity not found for pubkey {0}".format(pubkey))
         # Close client aiohttp session
-        sys.exit(1)
+        return
 
     # get the revoke document
     revocation_signed_raw_document = get_signed_raw_revocation_document(
@@ -166,4 +165,4 @@ def main():
 
 
 if __name__ == "__main__":
-    main()
+    save_revoke_document()
diff --git a/examples/send_certification.py b/examples/send_certification.py
index 0d50c041dcf68e555fdc54957b264cd3538a37f1..54bf2b7df20cc369e44edaecbccc4dde9d3851a3 100644
--- a/examples/send_certification.py
+++ b/examples/send_certification.py
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
-import sys
 import getpass
 from typing import Optional
 
@@ -98,7 +97,7 @@ def get_certification_document(
     )
 
 
-def main():
+def send_certification():
     """
     Main code
     """
@@ -130,7 +129,7 @@ def main():
     if identity is None:
         print("Identity not found for pubkey {0}".format(pubkey_to))
         # Close client aiohttp session
-        sys.exit(1)
+        return
 
     # send the Certification document to the node
     certification = get_certification_document(current_block, identity, pubkey_from)
@@ -148,4 +147,4 @@ def main():
 
 
 if __name__ == "__main__":
-    main()
+    send_certification()
diff --git a/examples/send_identity.py b/examples/send_identity.py
index b805e85b81b44f74bc2a352b84219bc254692ded..2bdc987440cefe5d01ccb42e4ba5b5abf581f157 100644
--- a/examples/send_identity.py
+++ b/examples/send_identity.py
@@ -67,7 +67,7 @@ def get_identity_document(
     return identity
 
 
-def main():
+def send_identity():
     """
     Main code
     """
@@ -105,4 +105,4 @@ def main():
 
 
 if __name__ == "__main__":
-    main()
+    send_identity()
diff --git a/examples/send_membership.py b/examples/send_membership.py
index 649447b1b8365fedc2087694e1890bb4c1832c3c..2506c9f44d0fd2f31d8530ddfd9888386b7cfe96 100644
--- a/examples/send_membership.py
+++ b/examples/send_membership.py
@@ -74,7 +74,7 @@ def get_membership_document(
     return membership
 
 
-def main():
+def send_membership():
     """
     Main code
     """
@@ -115,4 +115,4 @@ def main():
 
 
 if __name__ == "__main__":
-    main()
+    send_membership()
diff --git a/examples/send_transaction.py b/examples/send_transaction.py
index f841adcdea2531b130b29616b8759e529875dc82..5a6792c0b119b0eeb3179d74ff22750d675b0448 100644
--- a/examples/send_transaction.py
+++ b/examples/send_transaction.py
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
-import sys
 import getpass
 
 from duniterpy.api import bma
@@ -105,7 +104,7 @@ def get_transaction_document(
     return transaction
 
 
-def main():
+def send_transaction():
     """
     Main code
     """
@@ -137,7 +136,7 @@ def main():
 
     if len(response["sources"]) == 0:
         print("no sources found for account %s" % pubkey_to)
-        sys.exit(1)
+        return
 
     # get the first source
     source = response["sources"][0]
@@ -160,4 +159,4 @@ def main():
 
 
 if __name__ == "__main__":
-    main()
+    send_transaction()