diff --git a/Corona-Warn-App/build.gradle b/Corona-Warn-App/build.gradle
index d2613856d8e77f72ffcc6359503a3e649772c8e3..fbc02d5923a90fab89581c728c18680267cb1335 100644
--- a/Corona-Warn-App/build.gradle
+++ b/Corona-Warn-App/build.gradle
@@ -33,8 +33,8 @@ android {
         applicationId 'de.rki.coronawarnapp'
         minSdkVersion 23
         targetSdkVersion 29
-        versionCode 30
-        versionName "1.0.3"
+        versionCode 31
+        versionName "1.0.4"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
 
         buildConfigField "String", "DOWNLOAD_CDN_URL", "\"$DOWNLOAD_CDN_URL\""
diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/ProtoFormatConverterExtensions.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/ProtoFormatConverterExtensions.kt
index d0c657bb9ee40f76824ea695b39308257c5cab68..b7597b2cafa3faa737ac5786c8aed84aaf0deedb 100644
--- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/ProtoFormatConverterExtensions.kt
+++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/ProtoFormatConverterExtensions.kt
@@ -30,12 +30,12 @@ object ProtoFormatConverterExtensions {
     private const val MAXIMUM_KEYS = 14
 
     fun List<TemporaryExposureKey>.limitKeyCount() =
-        this.sortedWith(compareBy { it.rollingStartIntervalNumber }).asReversed().take(MAXIMUM_KEYS)
+        this.sortedWith(compareByDescending { it.rollingStartIntervalNumber }).take(MAXIMUM_KEYS)
 
     fun List<TemporaryExposureKey>.transformKeyHistoryToExternalFormat() =
-        this.sortedWith(compareBy { it.rollingStartIntervalNumber })
+        this.sortedWith(compareByDescending { it.rollingStartIntervalNumber })
             .mapIndexed { index, it ->
-                // The earliest key we receive is from yesterday (i.e. 1 day ago),
+                // The latest key we receive is from yesterday (i.e. 1 day ago),
                 // thus we need use index+1
                 val riskValue =
                     if (index + 1 <= DEFAULT_TRANSMISSION_RISK_VECTOR.lastIndex)
diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/ProtoFormatConverterExtensionsTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/ProtoFormatConverterExtensionsTest.kt
new file mode 100644
index 0000000000000000000000000000000000000000..9ffe27e56ca4d9ca4c6e2243be2751397d72cfa8
--- /dev/null
+++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/ProtoFormatConverterExtensionsTest.kt
@@ -0,0 +1,124 @@
+package de.rki.coronawarnapp.util
+
+import com.google.android.gms.nearby.exposurenotification.TemporaryExposureKey
+import de.rki.coronawarnapp.util.ProtoFormatConverterExtensions.transformKeyHistoryToExternalFormat
+import org.hamcrest.CoreMatchers
+import org.hamcrest.MatcherAssert
+import org.junit.Test
+
+private const val DEFAULT_TRANSMISSION_RISK_LEVEL = 1
+private const val TRANSMISSION_RISK_DAY_0 = 5
+private const val TRANSMISSION_RISK_DAY_1 = 6
+private const val TRANSMISSION_RISK_DAY_2 = 8
+private const val TRANSMISSION_RISK_DAY_3 = 8
+private const val TRANSMISSION_RISK_DAY_4 = 8
+private const val TRANSMISSION_RISK_DAY_5 = 5
+private const val TRANSMISSION_RISK_DAY_6 = 3
+private const val TRANSMISSION_RISK_DAY_7 = 1
+
+class ProtoFormatConverterExtensionsTest {
+
+    @Test
+    fun areTransmissionRiskLevelsCorrectlyAssigned() {
+
+        val key1 = byteArrayOf(
+            0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+            0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+        )
+
+        val diagnosisKeyList = mutableListOf<TemporaryExposureKey>()
+        val numKeys = 13
+        for (pos in 0 until numKeys) {
+            diagnosisKeyList.add(
+                TemporaryExposureKey.TemporaryExposureKeyBuilder()
+                    .setKeyData(key1)
+                    .setRollingStartIntervalNumber(pos * 144)
+                    .setRollingPeriod(144)
+                    .setTransmissionRiskLevel(0)
+                    .build()
+            )
+        }
+
+        val transformedKeyList = diagnosisKeyList.transformKeyHistoryToExternalFormat()
+            .sortedWith(compareBy { it.rollingStartIntervalNumber })
+
+        MatcherAssert.assertThat(
+            transformedKeyList.size,
+            CoreMatchers.equalTo(numKeys)
+        )
+
+        val correctRiskLevels = arrayOf(
+            DEFAULT_TRANSMISSION_RISK_LEVEL,
+            DEFAULT_TRANSMISSION_RISK_LEVEL,
+            DEFAULT_TRANSMISSION_RISK_LEVEL,
+            DEFAULT_TRANSMISSION_RISK_LEVEL,
+            DEFAULT_TRANSMISSION_RISK_LEVEL,
+            DEFAULT_TRANSMISSION_RISK_LEVEL,
+            TRANSMISSION_RISK_DAY_7,
+            TRANSMISSION_RISK_DAY_6,
+            TRANSMISSION_RISK_DAY_5,
+            TRANSMISSION_RISK_DAY_4,
+            TRANSMISSION_RISK_DAY_3,
+            TRANSMISSION_RISK_DAY_2,
+            TRANSMISSION_RISK_DAY_1
+        )
+
+        for (pos in 0 until numKeys) {
+            val key = transformedKeyList[pos]
+            MatcherAssert.assertThat(
+                key.transmissionRiskLevel,
+                CoreMatchers.equalTo(correctRiskLevels[pos])
+            )
+            MatcherAssert.assertThat(
+                key.rollingStartIntervalNumber,
+                CoreMatchers.equalTo(pos * 144)
+            )
+        }
+    }
+
+    @Test
+    fun areTransmissionRiskLevelsCorrectlyAssignedWithOnlyOneKey() {
+
+        val key1 = byteArrayOf(
+            0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+            0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+        )
+
+        val diagnosisKeyList = mutableListOf<TemporaryExposureKey>()
+        val numKeys = 1
+        for (pos in 0 until numKeys) {
+            diagnosisKeyList.add(
+                TemporaryExposureKey.TemporaryExposureKeyBuilder()
+                    .setKeyData(key1)
+                    .setRollingStartIntervalNumber(pos * 144)
+                    .setRollingPeriod(144)
+                    .setTransmissionRiskLevel(0)
+                    .build()
+            )
+        }
+
+        val transformedKeyList = diagnosisKeyList.transformKeyHistoryToExternalFormat()
+            .sortedWith(compareBy { it.rollingStartIntervalNumber })
+
+        MatcherAssert.assertThat(
+            transformedKeyList.size,
+            CoreMatchers.equalTo(numKeys)
+        )
+
+        val correctRiskLevels = arrayOf(
+            TRANSMISSION_RISK_DAY_1
+        )
+
+        for (pos in 0 until numKeys) {
+            val key = transformedKeyList[pos]
+            MatcherAssert.assertThat(
+                key.transmissionRiskLevel,
+                CoreMatchers.equalTo(correctRiskLevels[pos])
+            )
+            MatcherAssert.assertThat(
+                key.rollingStartIntervalNumber,
+                CoreMatchers.equalTo(pos * 144)
+            )
+        }
+    }
+}