diff --git a/broker/src/asapo_broker/database/encoding.go b/broker/src/asapo_broker/database/encoding.go
index 7c61d5428ce59cbdf5d112f8f04e721f426c8585..e1126fa844460bd53d688ea06323378d0755c084 100644
--- a/broker/src/asapo_broker/database/encoding.go
+++ b/broker/src/asapo_broker/database/encoding.go
@@ -3,7 +3,7 @@ package database
 import "net/url"
 
 func shouldEscape(c byte, db bool) bool {
-	if c == '$' || c == ' ' {
+	if c == '$' || c == ' ' || c == '%' {
 		return true
 	}
 	if !db {
diff --git a/broker/src/asapo_broker/database/encoding_test.go b/broker/src/asapo_broker/database/encoding_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..5f98641ef0d299133c1304aff476f4aa629ceab1
--- /dev/null
+++ b/broker/src/asapo_broker/database/encoding_test.go
@@ -0,0 +1,33 @@
+package database
+
+import (
+	"github.com/stretchr/testify/assert"
+	"testing"
+)
+
+func TestEncoding(t *testing.T) {
+	stream:=`ss$`
+	source :=`ads%&%41.sss`
+	streamEncoded := encodeStringForColName(stream)
+	sourceEncoded := encodeStringForDbName(source)
+	streamDecoded := decodeString(streamEncoded)
+	sourceDecoded := decodeString(sourceEncoded)
+	assert.Equal(t, streamDecoded, stream)
+	assert.Equal(t, sourceDecoded, source)
+
+	r := Request{
+		DbName:           source,
+		DbCollectionName: stream,
+		GroupId:          stream,
+		Op:               "",
+		DatasetOp:        false,
+		MinDatasetSize:   0,
+		ExtraParam:       "",
+	}
+	err := encodeRequest(&r)
+	assert.Equal(t, r.DbCollectionName, streamEncoded)
+	assert.Equal(t, r.GroupId, streamEncoded)
+	assert.Equal(t, r.DbName, sourceEncoded)
+
+	assert.Nil(t,err)
+}
diff --git a/common/cpp/src/database/CMakeLists.txt b/common/cpp/src/database/CMakeLists.txt
index 776cdc0555470e32a8df438bf6a3beb3d953e68f..16acadfd97e7da718467213db23cc3de7b0c7891 100644
--- a/common/cpp/src/database/CMakeLists.txt
+++ b/common/cpp/src/database/CMakeLists.txt
@@ -27,5 +27,5 @@ set(TEST_SOURCE_FILES ../../unittests/database/test_encoding.cpp)
 set(TEST_LIBRARIES "${TARGET_NAME}")
 
 include_directories(${ASAPO_CXX_COMMON_INCLUDE_DIR})
-gtest(${TARGET_NAME} "${TEST_SOURCE_FILES}" "${TEST_LIBRARIES}")
+gtest(${TARGET_NAME} "${TEST_SOURCE_FILES}" "${TEST_LIBRARIES}" "${CMAKE_CURRENT_SOURCE_DIR}/mongodb_client.cpp")
 
diff --git a/common/cpp/src/database/encoding.cpp b/common/cpp/src/database/encoding.cpp
index 131e7e26be7b8b3c382bc59573048fd5601b8e76..67048aa579baca4f76006fd7fc0cb7bde58725cc 100644
--- a/common/cpp/src/database/encoding.cpp
+++ b/common/cpp/src/database/encoding.cpp
@@ -5,7 +5,7 @@
 namespace asapo {
 
 bool ShouldEscape(char c, bool db) {
-    if (c == '$' || c == ' ') {
+    if (c == '$' || c == ' ' || c == '%') {
         return true;
     }
     if (!db) {
@@ -55,25 +55,22 @@ std::string Escape(const std::string &s, bool db) {
     return t;
 }
 
-
-inline int ishex(int x)
-{
-    return	(x >= '0' && x <= '9')	||
-        (x >= 'a' && x <= 'f')	||
+inline int ishex(int x) {
+    return (x >= '0' && x <= '9') ||
+        (x >= 'a' && x <= 'f') ||
         (x >= 'A' && x <= 'F');
 }
 
-int decode(const char *s, char *dec)
-{
-    char *o;
-    const char *end = s + strlen(s);
+int decode(const char* s, char* dec) {
+    char* o;
+    const char* end = s + strlen(s);
     int c;
 
     for (o = dec; s <= end; o++) {
         c = *s++;
 //        if (c == '+') c = ' ';
-        if (c == '%' && (	!ishex(*s++)	||
-            !ishex(*s++)	||
+        if (c == '%' && (!ishex(*s++) ||
+            !ishex(*s++) ||
             !sscanf(s - 2, "%2x", &c)))
             return -1;
         if (dec) *o = c;
@@ -82,7 +79,6 @@ int decode(const char *s, char *dec)
     return o - dec;
 }
 
-
 std::string EncodeDbName(const std::string &dbname) {
     return Escape(dbname, true);
 }
@@ -93,14 +89,14 @@ std::string EncodeColName(const std::string &colname) {
 
 std::string DecodeName(const std::string &name) {
     char decoded[name.size()];
-    auto res = decode(name.c_str(),decoded);
-    return res>=0?decoded:"";
+    auto res = decode(name.c_str(), decoded);
+    return res >= 0 ? decoded : "";
 }
 
 bool ShouldEscapeQuery(char c) {
     char chars[] = "-[]{}()*+?\\.,^$|#";
-    for (auto i=0;i<strlen(chars);i++) {
-        if (c==chars[i]) {
+    for (auto i = 0; i < strlen(chars); i++) {
+        if (c == chars[i]) {
             return true;
         }
     };