diff --git a/mpsd-software-environment.py b/mpsd-software-environment.py
index e9f21bb050ece8506adf45daea272f29bf224291..ff0c74d8c3cfbe890376b459c82d59f8e979afe2 100755
--- a/mpsd-software-environment.py
+++ b/mpsd-software-environment.py
@@ -7,7 +7,7 @@ import argparse
 import sys
 from pathlib import Path
 from typing import List, Tuple
-
+import datetime
 
 about_tool = """
 Build toolchains using Spack.\n
@@ -18,7 +18,7 @@ The toolchains are built using the bash script spack_setup.sh, and the results a
 """
 config_vars = {
     "cmd_log_file": "install.log",
-    "build_log_file": f"build_toolchains_mpsd_spack_ver_{time.strftime('%Y%m%d-%H%M%S')}.log",  # TODO: modify toolchains,mpsd_spack_ver when the variable is available
+    "build_log_file": f"logs/mpsd_spack_ver_toolchains_{datetime.datetime.now().replace(microsecond=0).isoformat()}.log",  # TODO: modify toolchains,mpsd_spack_ver when the variable is available
     "spack_environments_repo": "https://gitlab.gwdg.de/mpsd-cs/spack-environments.git",
 }
 
@@ -243,14 +243,18 @@ def install_environment(
     # Install the toolchains
     with os_chdir(toolchain_dir):
         # run spack_setup_script with the toolchains as arguments
+        # if the log folder doesn't exist, create it
+        if not os.path.exists("logs"):
+            os.mkdir("logs")
         for toolchain in toolchains:
             # Set the install log file name to config_vars["install_log_file"]
             # and replace _toolchains_ with the toolchain name and _mpsd_spack_ver_ with mpsd_release
+            
             print(f"Installing toolchain {toolchain} to {toolchain_dir}")
             install_log_file = (
                 config_vars["build_log_file"]
+                .replace("mpsd_spack_ver_", f"{mpsd_release}_")
                 .replace("_toolchains_", f"_{toolchain}_")
-                .replace("_mpsd_spack_ver_", f"_{mpsd_release}_")
             )
             subprocess.run(
                 f"bash {spack_setup_script} {' '.join(install_flags)} {toolchain} 2>&1 | tee -a {install_log_file} ",
@@ -332,5 +336,6 @@ def main():
         prepare_environment(args.release, script_dir)
 
 
+
 if __name__ == "__main__":
     main()
diff --git a/tests.py b/tests.py
index 1d0c95e549dfee216f6bcb806668959fd0ef5d32..a5e2a6196c918c1bae3b88f410e402dd1baca29a 100644
--- a/tests.py
+++ b/tests.py
@@ -118,7 +118,9 @@ def test_install_environment(tmp_path):
     # prepare dev-23a release
     # script_dir = tmp_path / "test_global_generic"
     # for actaual installation avoid tmp_path as the lenght of the path is too long and spack complains
-    script_dir = Path('/tmp/test_global_generic') 
+    script_dir = Path('/tmp/test_global_generic')
+    if script_dir.exists():
+        shutil.rmtree(script_dir)
     script_dir.mkdir(exist_ok=True, parents=True)
     spack_environments = "spack-environments"
     mpsd_release_to_test = "dev-23a"
@@ -162,8 +164,9 @@ def test_install_environment(tmp_path):
             script_dir=script_dir,
             enable_build_cache=False
         )
-    # assert that log files exists 
+    # assert that install log files exists 
     assert os.path.exists(release_base_dir/'install.log')
+    # assert that the module files are created correctly
     assert os.path.exists(release_base_dir/mpsd_microarch)
     assert os.path.exists(release_base_dir/mpsd_microarch/'lmod')
     # assert that lmod/module-index.yaml contains zlib
@@ -173,7 +176,9 @@ def test_install_environment(tmp_path):
     
     # test that the build log is created correctly
     # check that a file with glob build_globale_generic_dev-23a*.log exists at release_base_dir/mpsd_microarch
-    build_log = list((release_base_dir/mpsd_microarch).glob(f'build_{toolchain_to_test}_{mpsd_release_to_test}*.log'))
+    # print("Debug here ")
+    # time.sleep(10)
+    build_log = list((release_base_dir/mpsd_microarch/"logs").glob(f'{mpsd_release_to_test}_{toolchain_to_test}_*.log'))
     assert len(build_log) > 0
     # take the most recent build log
     build_log = sorted(build_log)[0]