diff --git a/bin/epm-release_downgrade b/bin/epm-release_downgrade
index b89badb196386f5d0b88de9a7e9b8a44dc256a4b..bc2efeef396cfc01504cb65e888cd0fd6e158f2e 100644
--- a/bin/epm-release_downgrade
+++ b/bin/epm-release_downgrade
@@ -37,10 +37,12 @@ get_prev_release()
 		echo "c8" ;;
 	"c8.2")
 		echo "c8.1" ;;
-	"c9")
-		echo "c8.2" ;;
-	"9")
-		echo "10" ;;
+	"c9f1")
+		echo "c8" ;;
+	"c9f2")
+		echo "c9f1" ;;
+	"10")
+		echo "9" ;;
 	*)
 		echo "$FROM" ;;
 	esac
diff --git a/bin/epm-release_upgrade b/bin/epm-release_upgrade
index e31626da334b35f9c9683cb078f5040674cbf1a5..3ca6e07872086d2e6c80d0ba6d0791778c047469 100644
--- a/bin/epm-release_upgrade
+++ b/bin/epm-release_upgrade
@@ -253,8 +253,10 @@ get_next_release()
 		echo "c8.1" ;;
 	"c8.1")
 		echo "c8.2" ;;
-	"c8.2")
-		echo "c9" ;;
+	"c8")
+		echo "c9f2" ;;
+	"c9f1")
+		echo "c9f2" ;;
 	*)
 		echo "$FROM" ;;
 	esac
@@ -321,7 +323,7 @@ __switch_alt_to_distro()
 			__check_system "$TO"
 			docmd epm update-kernel || fatal
 			;;
-		"p8"|"p8 p9"|"t8 p9"|"c8 c9"|"c8 p9"|"c8.1 p9"|"c8.2 p9"|"p9 p9"|"p9 c9")
+		"p8"|"p8 p9"|"t8 p9"|"c8 c9"|"c8 p9"|"c8.1 p9"|"c8.2 p9"|"p9 p9"|"p9 c9f2")
 			confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
 			docmd epm install rpm apt "$(get_fix_release_pkg "$FROM")" || fatal
 			info "Workaround for https://bugzilla.altlinux.org/show_bug.cgi?id=35492 ..."
@@ -386,7 +388,7 @@ __switch_alt_to_distro()
 			__check_system "$TO"
 			docmd epm upgrade || fatal
 			;;
-		"Sisyphus p8"|"Sisyphus p9"|"Sisyphus p10"|"Sisyphus c8"|"Sisyphus c8.1"|"Sisyphus c9")
+		"Sisyphus p8"|"Sisyphus p9"|"Sisyphus p10"|"Sisyphus c8"|"Sisyphus c8.1"|"Sisyphus c9f2")
 			confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
 			docmd epm install "$(get_fix_release_pkg "$FROM")"
 			__switch_repo_to $TO
diff --git a/bin/epm-repofix b/bin/epm-repofix
index b14c510cf5a025f39d6e161ef47347b0642b1637..54146982eb238494a882390b6747eb1aad8c78a2 100644
--- a/bin/epm-repofix
+++ b/bin/epm-repofix
@@ -46,10 +46,10 @@ __repofix_filter_vendor()
 	local br="$1"
 	br="$(echo "$br" | sed -e "s|\..*||")"
 	case $br in
-		c8)
+		c8*)
 			br="cert8"
 			;;
-		c9)
+		c9*)
 			br="cert9"
 			;;
 		Sisyphus)
diff --git a/tests/etc/ALTMED/etalon.txt b/tests/etc/ALTMED/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..7aa5715d53ec8c01919589ab6d9bc2a5e18daa92
--- /dev/null
+++ b/tests/etc/ALTMED/etalon.txt
@@ -0,0 +1 @@
+ALTLinux/p8
diff --git a/tests/etc/ALTSP8.4/etalon.txt b/tests/etc/ALTSP8.4/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..5a96ec35cdabecb2d785c49e476d192043800d1d
--- /dev/null
+++ b/tests/etc/ALTSP8.4/etalon.txt
@@ -0,0 +1 @@
+ALTLinux/c9f2
diff --git a/tests/etc/ALT/etc/os-release b/tests/etc/ALTSP8.4/etc/os-release
similarity index 100%
rename from tests/etc/ALT/etc/os-release
rename to tests/etc/ALTSP8.4/etc/os-release
diff --git a/tests/etc/ALTServer/etalon.txt b/tests/etc/ALTServer/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..6448586e8cb25f1dd4f1b1249609797d2f74edc2
--- /dev/null
+++ b/tests/etc/ALTServer/etalon.txt
@@ -0,0 +1 @@
+ALTServer/10
diff --git a/tests/etc/ALTWorkstation/etalon.txt b/tests/etc/ALTWorkstation/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..a946ba6bb554aa583e7576a78c736b912d63b846
--- /dev/null
+++ b/tests/etc/ALTWorkstation/etalon.txt
@@ -0,0 +1 @@
+ALTLinux/p10
diff --git a/tests/etc/AstraLinuxCE/etalon.txt b/tests/etc/AstraLinuxCE/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..c11ea0297e55709c60793f46c80677a7c38dbf84
--- /dev/null
+++ b/tests/etc/AstraLinuxCE/etalon.txt
@@ -0,0 +1 @@
+AstraLinux/2.12
diff --git a/tests/etc/AstraLinux/orel1/etc/os-release b/tests/etc/AstraLinuxCE/etc/os-release
similarity index 100%
rename from tests/etc/AstraLinux/orel1/etc/os-release
rename to tests/etc/AstraLinuxCE/etc/os-release
diff --git a/tests/etc/AstraLinuxCE2/etalon.txt b/tests/etc/AstraLinuxCE2/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..da837721e369c889d95060c81a95efb8993eb465
--- /dev/null
+++ b/tests/etc/AstraLinuxCE2/etalon.txt
@@ -0,0 +1 @@
+AstraLinux/2.12.44
diff --git a/tests/etc/AstraLinux/orel2/etc/os-release b/tests/etc/AstraLinuxCE2/etc/os-release
similarity index 100%
rename from tests/etc/AstraLinux/orel2/etc/os-release
rename to tests/etc/AstraLinuxCE2/etc/os-release
diff --git a/tests/etc/AstraLinuxSE/etalon.txt b/tests/etc/AstraLinuxSE/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..1e109c09d632d3584b4bf6ffdde092b47bf2cbea
--- /dev/null
+++ b/tests/etc/AstraLinuxSE/etalon.txt
@@ -0,0 +1 @@
+AstraLinux/1.7
diff --git a/tests/etc/AstraLinuxSE/etc/os-release b/tests/etc/AstraLinuxSE/etc/os-release
new file mode 100644
index 0000000000000000000000000000000000000000..ce7735b6de690b0108780a197b5968a06fac774c
--- /dev/null
+++ b/tests/etc/AstraLinuxSE/etc/os-release
@@ -0,0 +1,10 @@
+PRETTY_NAME="Astra Linux"
+NAME="Astra Linux"
+ID=astra
+ID_LIKE=debian
+ANSI_COLOR="1;31"
+HOME_URL="https://astralinux.ru"
+SUPPORT_URL="https://astralinux.ru/support"
+LOGO=astra
+VERSION_ID=1.7_x86-64
+VERSION_CODENAME=1.7_x86-64
diff --git a/tests/etc/MESh/etalon.txt b/tests/etc/MESh/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..7581c1b9eba31bdf18c39a9f0be36ac1f6cb54b8
--- /dev/null
+++ b/tests/etc/MESh/etalon.txt
@@ -0,0 +1 @@
+MESh/10
diff --git a/tests/etc/Manjaro/etalon.txt b/tests/etc/Manjaro/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..cc919dea63386bf3d66b802b601f864d25bfa334
--- /dev/null
+++ b/tests/etc/Manjaro/etalon.txt
@@ -0,0 +1 @@
+ManjaroLinux/CUR
diff --git a/tests/etc/os-release b/tests/etc/Manjaro/etc/os-release
similarity index 100%
rename from tests/etc/os-release
rename to tests/etc/Manjaro/etc/os-release
diff --git a/tests/etc/RHEL/etalon.txt b/tests/etc/RHEL/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..e9f2c4085be6dec6984ffea4eb8bde11bb742544
--- /dev/null
+++ b/tests/etc/RHEL/etalon.txt
@@ -0,0 +1 @@
+RHEL/7.9
diff --git a/tests/etc/ROSA/etalon.txt b/tests/etc/ROSA/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..f0931c12b90940f7c7589f2c277d626c2a42a70c
--- /dev/null
+++ b/tests/etc/ROSA/etalon.txt
@@ -0,0 +1 @@
+RELS/7.9
diff --git a/tests/etc/ROSA12/etalon.txt b/tests/etc/ROSA12/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..02297af735610f69256eee2316a79647d3496e7f
--- /dev/null
+++ b/tests/etc/ROSA12/etalon.txt
@@ -0,0 +1 @@
+ROSA/2021.1
diff --git a/tests/etc/altlinux-release b/tests/etc/altlinux-release
deleted file mode 100644
index bbd1388017087d8c9f72563d340b80291d1cad31..0000000000000000000000000000000000000000
--- a/tests/etc/altlinux-release
+++ /dev/null
@@ -1 +0,0 @@
-ALT Workstation K 9.0 BETA (Centaurea Ruthenica)
diff --git a/tests/etc/openSUSE/etalon.txt b/tests/etc/openSUSE/etalon.txt
new file mode 100644
index 0000000000000000000000000000000000000000..26ec8d823ab5d55c69784d92a6569517e3b27e32
--- /dev/null
+++ b/tests/etc/openSUSE/etalon.txt
@@ -0,0 +1 @@
+openSUSE Tumbleweed/20161014
diff --git a/tests/etc/lsb-release b/tests/etc/openSUSE/etc/lsb-release
similarity index 100%
rename from tests/etc/lsb-release
rename to tests/etc/openSUSE/etc/lsb-release
diff --git a/tests/test_distr_info.sh b/tests/test_distr_info.sh
new file mode 100755
index 0000000000000000000000000000000000000000..bef1ad122a18fc0f95a2a43e4f85fbbe33c54e4d
--- /dev/null
+++ b/tests/test_distr_info.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+WRITE=''
+[ "$1" = "--write" ] && WRITE=1
+
+for ROOTDIR in $(ls -1d etc/*) ; do
+    export ROOTDIR
+    e=$(../bin/distr_info -e)
+    if [ -n "$WRITE" ] ; then
+        echo "$e" > $ROOTDIR/etalon.txt
+        continue
+    fi
+    le="$(cat $ROOTDIR/etalon.txt 2>/dev/null)"
+    if [ "$le" = "$e" ] ; then
+        printf "%23s -> %20s : %s\n" "$(basename $ROOTDIR)" "$e" "OK"
+    else
+        printf "%23s -> %20s : %s\n" "$(basename $ROOTDIR)" "$e" "FAIL (expect $le)"
+    fi
+done
+
diff --git a/tests/test_versions.sh b/tests/test_versions.sh
new file mode 100755
index 0000000000000000000000000000000000000000..163ce31049c8f7980a5b09f4f1dd8feab89fc1b6
--- /dev/null
+++ b/tests/test_versions.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+check()
+{
+    [ "$2" != "$3" ] && echo "FATAL with '$1': result '$3' do not match with '$2'" || echo "OK for '$1' with '$2'"
+}
+
+# 1.2.3.4.5 -> 1
+normalize_version1()
+{
+    echo "$1" | sed -e "s|\..*||"
+}
+
+# 1.2.3.4.5 -> 1.2
+normalize_version2()
+{
+    echo "$1" | sed -e "s|^\([^.][^.]*\.[^.][^.]*\)\..*|\1|"
+}
+
+# 1.2.3.4.5 -> 1.2.3
+normalize_version3()
+{
+    echo "$1" | sed -e "s|^\([^.][^.]*\.[^.][^.]*\.[^.][^.]*\)\..*|\1|"
+}
+
+
+test1()
+{
+    check "$1" "$2" "$(normalize_version1 "$1")"
+}
+
+test2()
+{
+    check "$1" "$2" "$(normalize_version2 "$1")"
+}
+
+test3()
+{
+    check "$1" "$2" "$(normalize_version3 "$1")"
+}
+
+echo
+echo " 1"
+test1 1              1
+test1 10             10
+test1 10.1           10
+test1 10.01          10
+test1 1.1            1
+test1 1.1.1          1
+test1 1.2.3.4        1
+test1 1.2.3.4.5      1
+test1 123            123
+
+echo
+echo " 2"
+test2 2.1            2.1
+test2 2              2
+test2 10             10
+test2 10.1           10.1
+test2 10.01          10.01
+test2 1.1            1.1
+test2 1.1.1          1.1
+test2 1.2.3.4        1.2
+test2 1.2.3.4.5      1.2
+test2 123            123
+
+echo
+echo " 3"
+test3 2.1            2.1
+test3 2              2
+test3 10             10
+test3 10.1           10.1
+test3 10.01          10.01
+test3 1.1            1.1
+test3 1.1.1          1.1.1
+test3 1.2.3.4        1.2.3
+test3 1.2.3.4.5      1.2.3
+test3 1.2.3.4.5.6    1.2.3
+test3 123            123