diff --git a/src/amf/amfd/role.cc b/src/amf/amfd/role.cc
index f98beea01..aac90eb13 100644
--- a/src/amf/amfd/role.cc
+++ b/src/amf/amfd/role.cc
@@ -1220,7 +1220,7 @@ uint32_t amfd_switch_stdby_actv(AVD_CL_CB *cb) {
   rc = consensus_service.BeginActivePromotion();
   if (rc != SA_AIS_OK) {
     LOG_ER("Unable to set active controller in consensus service");
-    LOG_ER("Split brain is possible");
+    osafassert(false);
   }
 
   /* Declare this standby as Active. Set Vdest role role */
diff --git a/src/fm/fmd/fm_main.cc b/src/fm/fmd/fm_main.cc
index 1d3cba766..65cd6e440 100644
--- a/src/fm/fmd/fm_main.cc
+++ b/src/fm/fmd/fm_main.cc
@@ -554,6 +554,8 @@ static void fm_mbx_msg_handler(FM_CB *fm_cb, FM_EVT *fm_mbx_evt)
 	TRACE_ENTER();
 	switch (fm_mbx_evt->evt_code) {
 	case FM_EVT_NODE_DOWN:
+	{
+		Consensus consensus_service;
 		LOG_NO("Current role: %s", role_string[fm_cb->role]);
 		if ((fm_mbx_evt->node_id == fm_cb->peer_node_id)) {
 			/* Check whether node(AMF) initialization is done */
@@ -596,19 +598,24 @@ static void fm_mbx_msg_handler(FM_CB *fm_cb, FM_EVT *fm_mbx_evt)
 				 */
 				if (fm_cb->role == PCS_RDA_STANDBY) {
 					// update consensus service, before fencing old active controller
-					Consensus consensus_service;
 					consensus_service.DemoteCurrentActive();
 				}
 
 				if (fm_cb->use_remote_fencing) {
 					if (fm_cb->peer_node_terminated ==
 					    false) {
+						if (consensus_service.IsEnabled() == false ||
+						    consensus_service.IsWritable() == true) {
 						opensaf_reboot(
 						    fm_cb->peer_node_id,
 						    (char *)fm_cb
 							->peer_clm_node_name
 							.value,
 						    "Received Node Down for peer controller");
+						} else {
+							LOG_NO("This node does not have write access to consensus service.");
+							LOG_NO("Fencing will not be performed");
+						}
 					} else {
 						LOG_NO(
 						    "Peer node %s is terminated, fencing will not be performed",
@@ -631,6 +638,7 @@ static void fm_mbx_msg_handler(FM_CB *fm_cb, FM_EVT *fm_mbx_evt)
 				}
 			}
 		}
+		}
 		break;
 
 	case FM_EVT_PEER_UP:
diff --git a/src/fm/fmd/fm_rda.cc b/src/fm/fmd/fm_rda.cc
index 0cec70a05..b1c17fcc7 100644
--- a/src/fm/fmd/fm_rda.cc
+++ b/src/fm/fmd/fm_rda.cc
@@ -21,6 +21,7 @@
 #include "rde/agent/rda_papi.h"
 #include "osaf/consensus/service.h"
 #include "base/logtrace.h"
+#include "base/ncssysf_def.h"
 
 extern void rda_cb(uint32_t cb_hdl, PCS_RDA_CB_INFO *cb_info,
        PCSRDA_RETURN_CODE error_code);
@@ -96,7 +97,8 @@ uint32_t fm_rda_set_role(FM_CB *fm_cb, PCS_RDA_ROLE role)
 	rc = consensus_service.BeginActivePromotion();
 	if (rc != SA_AIS_OK) {
 		LOG_ER("Unable to set active controller in consensus service");
-		LOG_ER("Split brain is possible");
+		opensaf_reboot(0, nullptr,
+			"Unable to set active controller in consensus service");
 	}
 
 	rc = pcs_rda_request(&rda_req);
diff --git a/src/osaf/consensus/keyvalue.cc b/src/osaf/consensus/keyvalue.cc
index e5a796d33..bf54f28b5 100644
--- a/src/osaf/consensus/keyvalue.cc
+++ b/src/osaf/consensus/keyvalue.cc
@@ -14,7 +14,7 @@
  * Author(s): Ericsson AB
  *
  */
-#include "keyvalue.h"
+#include "osaf/consensus/keyvalue.h"
 #include "base/logtrace.h"
 #include "base/getenv.h"
 #include "base/conf.h"
@@ -45,7 +45,8 @@ int KeyValue::Execute(const std::string& command, std::string& output) {
 SaAisErrorT KeyValue::Get(const std::string& key, std::string& value) {
   TRACE_ENTER();
 
-  const std::string kv_store_cmd = base::GetEnv("KEYVALUE_STORE_PLUGIN_CMD", "");
+  const std::string kv_store_cmd = base::GetEnv(
+    "KEYVALUE_STORE_PLUGIN_CMD", "");
   const std::string command(kv_store_cmd + " get " + key);
   int rc = KeyValue::Execute(command, value);
   TRACE("Read '%s'", value.c_str());
@@ -60,7 +61,8 @@ SaAisErrorT KeyValue::Get(const std::string& key, std::string& value) {
 SaAisErrorT KeyValue::Set(const std::string& key, const std::string& value) {
   TRACE_ENTER();
 
-  const std::string kv_store_cmd = base::GetEnv("KEYVALUE_STORE_PLUGIN_CMD", "");
+  const std::string kv_store_cmd = base::GetEnv(
+    "KEYVALUE_STORE_PLUGIN_CMD", "");
   const std::string command(kv_store_cmd + " set " + key + " " + value);
   std::string output;
   int rc = KeyValue::Execute(command, output);
@@ -75,7 +77,8 @@ SaAisErrorT KeyValue::Set(const std::string& key, const std::string& value) {
 SaAisErrorT KeyValue::Erase(const std::string& key) {
   TRACE_ENTER();
 
-  const std::string kv_store_cmd = base::GetEnv("KEYVALUE_STORE_PLUGIN_CMD", "");
+  const std::string kv_store_cmd = base::GetEnv(
+    "KEYVALUE_STORE_PLUGIN_CMD", "");
   const std::string command(kv_store_cmd + " erase " + key);
   std::string output;
   int rc = KeyValue::Execute(command, output);
@@ -91,9 +94,10 @@ SaAisErrorT KeyValue::Lock(const std::string& owner,
                          const unsigned int timeout) {
   TRACE_ENTER();
 
-  const std::string kv_store_cmd = base::GetEnv("KEYVALUE_STORE_PLUGIN_CMD", "");
+  const std::string kv_store_cmd = base::GetEnv(
+    "KEYVALUE_STORE_PLUGIN_CMD", "");
   const std::string command(kv_store_cmd + " lock " + owner + " " +
-                      std::to_string(timeout));
+    std::to_string(timeout));
   std::string output;
   int rc = KeyValue::Execute(command, output);
 
@@ -104,11 +108,12 @@ SaAisErrorT KeyValue::Lock(const std::string& owner,
   }
 }
 
-SaAisErrorT KeyValue::Unlock() {
+SaAisErrorT KeyValue::Unlock(const std::string& owner) {
   TRACE_ENTER();
 
-  const std::string kv_store_cmd = base::GetEnv("KEYVALUE_STORE_PLUGIN_CMD", "");
-  const std::string command(kv_store_cmd + " unlock");
+  const std::string kv_store_cmd = base::GetEnv(
+    "KEYVALUE_STORE_PLUGIN_CMD", "");
+  const std::string command(kv_store_cmd + " unlock " + owner);
   std::string output;
   int rc = Execute(command, output);
 
@@ -122,7 +127,8 @@ SaAisErrorT KeyValue::Unlock() {
 bool KeyValue::IsLockedByThisNode() {
   TRACE_ENTER();
 
-  const std::string kv_store_cmd = base::GetEnv("KEYVALUE_STORE_PLUGIN_CMD", "");
+  const std::string kv_store_cmd = base::GetEnv(
+    "KEYVALUE_STORE_PLUGIN_CMD", "");
   const std::string command(kv_store_cmd + " lock_owner");
   std::string output;
   int rc = KeyValue::Execute(command, output);
@@ -142,7 +148,8 @@ void threadFunction(const std::string& key,
   const uint32_t user_defined) {
   TRACE_ENTER();
 
-  const std::string kv_store_cmd = base::GetEnv("KEYVALUE_STORE_PLUGIN_CMD", "");
+  const std::string kv_store_cmd = base::GetEnv(
+    "KEYVALUE_STORE_PLUGIN_CMD", "");
   const std::string command(kv_store_cmd + " watch " + key);
   std::string value;
   int rc = KeyValue::Execute(command, value);
@@ -157,8 +164,7 @@ void threadFunction(const std::string& key,
 
 void KeyValue::Watch(const std::string& key,
   const ConsensusCallback callback,
-  const uint32_t user_defined)
-{
+  const uint32_t user_defined) {
   std::thread t(threadFunction, key, callback, user_defined);
   t.detach();
   return;
diff --git a/src/osaf/consensus/keyvalue.h b/src/osaf/consensus/keyvalue.h
index 347c820d0..55d096a61 100644
--- a/src/osaf/consensus/keyvalue.h
+++ b/src/osaf/consensus/keyvalue.h
@@ -14,8 +14,8 @@
  * Author(s): Ericsson AB
  *
  */
-#ifndef CONSENSUS_KEYVALUE_H_
-#define CONSENSUS_KEYVALUE_H_
+#ifndef OSAF_CONSENSUS_KEYVALUE_H_
+#define OSAF_CONSENSUS_KEYVALUE_H_
 
 #include <saAis.h>
 #include <string>
@@ -41,7 +41,7 @@ class KeyValue {
     const unsigned int timeout = 20);
 
   // Release lock
-  static SaAisErrorT Unlock();
+  static SaAisErrorT Unlock(const std::string& owner);
 
   // Is locked by this node?
   static bool IsLockedByThisNode();
@@ -54,4 +54,4 @@ class KeyValue {
   static int Execute(const std::string& command, std::string& output);
 };
 
-#endif
+#endif  // OSAF_CONSENSUS_KEYVALUE_H_
diff --git a/src/osaf/consensus/plugins/etcd.plugin b/src/osaf/consensus/plugins/etcd.plugin
index 0b8c77b4e..784bb7c0e 100644
--- a/src/osaf/consensus/plugins/etcd.plugin
+++ b/src/osaf/consensus/plugins/etcd.plugin
@@ -12,8 +12,8 @@ readonly keyname="opensaf_consensus_lock"
 get() {
   local readonly key=$1
 
-  value=`etcdctl get $key 2>&1`
-  if [ $? -eq 0 ]; then
+  if value=$(etcdctl get "$key" 2>&1)
+  then
     echo "$value"
     return 0
   else
@@ -33,8 +33,8 @@ set() {
   local readonly key=$1
   local readonly value=$2
 
-  etcdctl set $key $value 1>& /dev/null
-  if [ $? -eq 0 ]; then
+  if etcdctl set "$key" "$value" 1>& /dev/null
+  then
     return 0
   else
     return 1
@@ -51,8 +51,8 @@ set() {
 erase() {
   local readonly key=$1
 
-  etcdctl rm $key 1>& /dev/null
-  if [ $? -eq 0 ]; then
+  if etcdctl rm "$key" 1>& /dev/null
+  then
     return 0
   else
     return 1
@@ -71,16 +71,16 @@ lock() {
   local readonly timeout=$2
 
   #implementation here
-  etcdctl mk $keyname $owner --ttl $timeout >& /dev/null
-  if [ $? -ne 0 ]; then
-    current_owner=`etcdctl get $keyname`
+  if etcdctl mk "$keyname" "$owner" --ttl "$timeout" >& /dev/null
+  then
+    return 0
+  else
+    current_owner=$(etcdctl get $keyname)
     # see if we already hold the lock
     if [ "$current_owner" == "$owner" ]; then
       return 0
     fi
     return 1
-  else
-    return 0
   fi
 }
 
@@ -98,7 +98,8 @@ lock_owner() {
 
 # unlock
 # params:
-#   $1 - <forced>
+#   $1 - owner
+#   $2 - <forced>
 #      - (optional parameter)
 #      - if set 'true', will unlock even if lock is not held by node
 #      - defaults to 'false'
@@ -107,19 +108,19 @@ lock_owner() {
 #   non-zero - failure
 #
 unlock() {
-  local readonly forced=${1:-false}
-  local readonly hostname=$(hostname)
+  local readonly owner=$1
+  local readonly forced=${2:-false}
 
   if [ "$forced" = false ]; then
     # check we own the lock
-    owner=`etcdctl get $keyname 2>&1`
-    if [ "$owner" != "$hostname" ]; then
+    current_owner=$(etcdctl get $keyname 2>&1)
+    if [ "$owner" != "$current_owner" ]; then
       return 1
     fi
   fi
 
-  etcdctl rm $keyname >& /dev/null
-  if [ $? -eq 0 ]; then
+  if etcdctl rm $keyname >& /dev/null
+  then
     return 0
   else
     return 1
@@ -136,8 +137,8 @@ unlock() {
 watch() {
   local readonly key=$1
 
-  value=`etcdctl watch $key 2>&1`
-  if [ $? -eq 0 ]; then
+  if value=$(etcdctl watch "$key" 2>&1)
+  then
     # if the key is removed, then "PrevNode.Value: <value>" is returned
     echo "$value"
     return 0
@@ -154,7 +155,7 @@ case "$1" in
       echo "Usage: $0 get <key>"
       exit 1
     fi
-    get $2
+    get "$2"
     exit $?
     ;;
   set)
@@ -162,7 +163,7 @@ case "$1" in
       echo "Usage: $0 set <key> <value>"
       exit 1
     fi
-    set $2 $3
+    set "$2" "$3"
     exit $?
     ;;
   erase)
@@ -170,7 +171,7 @@ case "$1" in
       echo "Usage: $0 erase <key>"
       exit 1
     fi
-    erase $2 ""
+    erase "$2"
     exit $?
     ;;
   lock)
@@ -178,7 +179,7 @@ case "$1" in
       echo "Usage: $0 lock <owner> <timeout>"
       exit 1
     fi
-    lock $2 $3
+    lock "$2" "$3"
     exit $?
     ;;
   lock_owner)
@@ -190,14 +191,14 @@ case "$1" in
     exit $?
     ;;
   unlock)
-    if [ "$#" -eq 1 ]; then
-      unlock
+    if [ "$#" -eq 2 ]; then
+      unlock "$2"
       exit $?
-    elif [ "$#" -eq 2 ] && [ "$2" == "--force" ]; then
-      unlock 1
+    elif [ "$#" -eq 3 ] && [ "$3" == "--force" ]; then
+      unlock "$2" 1
       exit $?
     else
-      echo "Usage: $0 unlock [--force]"
+      echo "Usage: $0 unlock <owner> [--force]"
       exit 1
     fi
     ;;
@@ -206,11 +207,11 @@ case "$1" in
       echo "Usage: $0 watch <key>"
       exit 1
     fi
-    watch $2
+    watch "$2"
     exit $?
     ;;
   *)
-    echo $"Usage: $0 {get|set|erase|lock|unlock|lock_owner|watch}"
+    echo "Usage: $0 {get|set|erase|lock|unlock|lock_owner|watch}"
     ;;
 esac
 
diff --git a/src/osaf/consensus/plugins/sample.plugin b/src/osaf/consensus/plugins/sample.plugin
index 424982448..a3656ec82 100644
--- a/src/osaf/consensus/plugins/sample.plugin
+++ b/src/osaf/consensus/plugins/sample.plugin
@@ -66,7 +66,8 @@ lock_owner() {
 
 # unlock
 # params:
-#   $1 - <forced>
+#   $1 - owner
+#   $2 - <forced>
 #      - (optional parameter)
 #      - if set 'true', will unlock even if lock is not held by node
 #      - defaults to 'false'
@@ -75,8 +76,8 @@ lock_owner() {
 #   non-zero - failure
 #
 unlock() {
-  local readonly forced=${1:-false}
-  local readonly hostname=$(hostname)
+  local readonly owner=$1
+  local readonly forced=${2:-false}
   ...
 }
 
@@ -99,7 +100,7 @@ case "$1" in
       echo "Usage: $0 get <key>"
       exit 1
     fi
-    get $2
+    get "$2"
     exit $?
     ;;
   set)
@@ -107,7 +108,7 @@ case "$1" in
       echo "Usage: $0 set <key> <value>"
       exit 1
     fi
-    set $2 $3
+    set "$2" "$3"
     exit $?
     ;;
   erase)
@@ -115,7 +116,7 @@ case "$1" in
       echo "Usage: $0 erase <key>"
       exit 1
     fi
-    erase $2 ""
+    erase "$2"
     exit $?
     ;;
   lock)
@@ -123,7 +124,7 @@ case "$1" in
       echo "Usage: $0 lock <owner> <timeout>"
       exit 1
     fi
-    lock $2 $3
+    lock "$2" "$3"
     exit $?
     ;;
   lock_owner)
@@ -135,14 +136,14 @@ case "$1" in
     exit $?
     ;;
   unlock)
-    if [ "$#" -eq 1 ]; then
-      unlock
+    if [ "$#" -eq 2 ]; then
+      unlock "$2"
       exit $?
-    elif [ "$#" -eq 2 ] && [ "$2" == "--force" ]; then
-      unlock 1
+    elif [ "$#" -eq 3 ] && [ "$3" == "--force" ]; then
+      unlock "$2" 1
       exit $?
     else
-      echo "Usage: $0 unlock [--force]"
+      echo "Usage: $0 unlock <owner> [--force]"
       exit 1
     fi
     ;;
@@ -151,11 +152,11 @@ case "$1" in
       echo "Usage: $0 watch <key>"
       exit 1
     fi
-    watch $2
+    watch "$2"
     exit $?
     ;;
   *)
-    echo $"Usage: $0 {get|set|erase|lock|unlock|lock_owner|watch}"
+    echo "Usage: $0 {get|set|erase|lock|unlock|lock_owner|watch}"
     ;;
 esac
 
diff --git a/src/osaf/consensus/service.cc b/src/osaf/consensus/service.cc
index fd525b6d3..3227bd807 100644
--- a/src/osaf/consensus/service.cc
+++ b/src/osaf/consensus/service.cc
@@ -14,13 +14,14 @@
  * Author(s): Ericsson AB
  *
  */
-#include "service.h"
+#include "osaf/consensus/service.h"
+#include <unistd.h>
+#include <climits>
+#include <thread>
 #include "base/logtrace.h"
 #include "base/conf.h"
 #include "base/getenv.h"
 #include "base/ncssysf_def.h"
-#include <unistd.h>
-#include <climits>
 
 SaAisErrorT Consensus::BeginActivePromotion() {
   TRACE_ENTER();
@@ -30,26 +31,35 @@ SaAisErrorT Consensus::BeginActivePromotion() {
     return SA_AIS_OK;
   }
 
-  rc = KeyValue::Lock(base::Conf::NodeName(), 30);
-  while (rc != SA_AIS_OK) {
+  uint32_t retries = 0;
+  rc = KeyValue::Lock(base::Conf::NodeName(), kLockTimeout);
+  while (rc != SA_AIS_OK && retries < kMaxRetry) {
     TRACE("Waiting for lock");
-    usleep(sleep_internal);
-    rc = KeyValue::Lock(base::Conf::NodeName(), 30);
+    ++retries;
+    std::this_thread::sleep_for(kSleepInterval);
+    rc = KeyValue::Lock(base::Conf::NodeName(), kLockTimeout);
   }
 
   LOG_IN("Node %s obtained lock", base::Conf::NodeName().c_str());
 
   // check current active node
   std::string current;
+  bool current_valid = false;
   rc = KeyValue::Get(keyname, current);
   if (rc == SA_AIS_OK) {
+    current_valid = true;
     LOG_NO("Current active controller is %s", current.c_str());
+  }
+
+  LOG_NO("Setting active controller to %s", base::Conf::NodeName().c_str());
+  rc = KeyValue::Set(keyname, base::Conf::NodeName());
+
+  if (current_valid == true) {
     if (current != base::Conf::NodeName()) {
+      // fence the old active controller
       FenceNode(current);
     }
   }
-  LOG_NO("Setting active controller to %s", base::Conf::NodeName().c_str());
-  rc = KeyValue::Set(keyname, base::Conf::NodeName());
   return rc;
 }
 
@@ -63,31 +73,34 @@ SaAisErrorT Consensus::EndActivePromotion() {
   if (locked == false) {
     LOG_ER("Lock unexpectedly released");
   } else {
+    uint32_t retries = 0;
     SaAisErrorT rc;
-    rc = KeyValue::Unlock();
-    while (rc != SA_AIS_OK) {
+    rc = KeyValue::Unlock(base::Conf::NodeName());
+    while (rc != SA_AIS_OK && retries < kMaxRetry) {
       LOG_IN("Trying to unlock");
-      usleep(sleep_internal);
-      rc = KeyValue::Unlock();
+      ++retries;
+      std::this_thread::sleep_for(kSleepInterval);
+      rc = KeyValue::Unlock(base::Conf::NodeName());
     }
     LOG_IN("Released lock");
   }
   return SA_AIS_OK;
 }
 
-SaAisErrorT Consensus::Demote(const std::string node = "")
-{
+SaAisErrorT Consensus::Demote(const std::string& node = "") {
   TRACE_ENTER();
   SaAisErrorT rc;
   if (use_consensus_ == false) {
     return SA_AIS_OK;
   }
 
-  rc = KeyValue::Lock(base::Conf::NodeName(), 30);
-  while (rc != SA_AIS_OK) {
+  uint32_t retries = 0;
+  rc = KeyValue::Lock(base::Conf::NodeName(), kLockTimeout);
+  while (rc != SA_AIS_OK && retries < kMaxRetry) {
     LOG_IN("Waiting for lock");
-    usleep(sleep_internal);
-    rc = KeyValue::Lock(base::Conf::NodeName(), 30);
+    ++retries;
+    std::this_thread::sleep_for(kSleepInterval);
+    rc = KeyValue::Lock(base::Conf::NodeName(), kLockTimeout);
   }
 
   // check current active node
@@ -108,11 +121,13 @@ SaAisErrorT Consensus::Demote(const std::string node = "")
     LOG_NO("Node %s demoted", current.c_str());
   }
 
-  rc = KeyValue::Unlock();
-  while (rc != SA_AIS_OK) {
+  retries = 0;
+  rc = KeyValue::Unlock(base::Conf::NodeName());
+  while (rc != SA_AIS_OK && retries < kMaxRetry) {
     LOG_IN("Trying to unlock");
-    usleep(sleep_internal);
-    rc = KeyValue::Unlock();
+    ++retries;
+    std::this_thread::sleep_for(kSleepInterval);
+    rc = KeyValue::Unlock(base::Conf::NodeName());
   }
   LOG_IN("Released lock");
 
@@ -133,6 +148,21 @@ bool Consensus::IsEnabled() const {
   return use_consensus_;
 }
 
+bool Consensus::IsWritable() const {
+  TRACE_ENTER();
+  if (use_consensus_ == false) {
+    return true;
+  }
+
+  SaAisErrorT rc;
+  rc = KeyValue::Set(test_keyname, base::Conf::NodeName());
+  if (rc == SA_AIS_OK) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
 std::string Consensus::CurrentActive() const {
   TRACE_ENTER();
   SaAisErrorT rc;
@@ -141,11 +171,13 @@ std::string Consensus::CurrentActive() const {
     return "";
   }
 
-  rc = KeyValue::Lock(base::Conf::NodeName(), 30);
-  while (rc != SA_AIS_OK) {
+  uint32_t retries = 0;
+  rc = KeyValue::Lock(base::Conf::NodeName(), kLockTimeout);
+  while (rc != SA_AIS_OK && retries < kMaxRetry) {
     LOG_IN("Waiting for lock");
-    usleep(sleep_internal);
-    rc = KeyValue::Lock(base::Conf::NodeName(), 30);
+    ++retries;
+    std::this_thread::sleep_for(kSleepInterval);
+    rc = KeyValue::Lock(base::Conf::NodeName(), kLockTimeout);
   }
 
   // check current active node
@@ -156,11 +188,13 @@ std::string Consensus::CurrentActive() const {
     LOG_IN("Current active controller is %s", current.c_str());
   }
 
-  rc = KeyValue::Unlock();
-  while (rc != SA_AIS_OK) {
+  retries = 0;
+  rc = KeyValue::Unlock(base::Conf::NodeName());
+  while (rc != SA_AIS_OK && retries < kMaxRetry) {
     LOG_IN("Trying to unlock");
-    usleep(sleep_internal);
-    rc = KeyValue::Unlock();
+    ++retries;
+    std::this_thread::sleep_for(kSleepInterval);
+    rc = KeyValue::Unlock(base::Conf::NodeName());
   }
 
   LOG_IN("Released lock");
@@ -199,12 +233,10 @@ Consensus::Consensus() {
   }
 }
 
-Consensus::~Consensus()
-{
+Consensus::~Consensus() {
 }
 
-bool Consensus::FenceNode(const std::string& node)
-{
+bool Consensus::FenceNode(const std::string& node) {
   if (use_remote_fencing_ == true) {
     LOG_WA("Fencing remote node %s", node.c_str());
     // @todo currently passing UINT_MAX as node ID, since
@@ -220,8 +252,7 @@ bool Consensus::FenceNode(const std::string& node)
 }
 
 void Consensus::MonitorActive(ConsensusCallback callback,
-  const uint32_t user_defined)
-{
+  const uint32_t user_defined) {
   TRACE_ENTER();
   if (use_consensus_ == false) {
     return;
diff --git a/src/osaf/consensus/service.h b/src/osaf/consensus/service.h
index 03f7f26f9..0ca504cbf 100644
--- a/src/osaf/consensus/service.h
+++ b/src/osaf/consensus/service.h
@@ -14,16 +14,16 @@
  * Author(s): Ericsson AB
  *
  */
-#ifndef CONSENSUS_SERVICE_H_
-#define CONSENSUS_SERVICE_H_
+#ifndef OSAF_CONSENSUS_SERVICE_H_
+#define OSAF_CONSENSUS_SERVICE_H_
 
-#include "keyvalue.h"
-#include "saAis.h"
+#include <chrono>
 #include <string>
+#include "saAis.h"
+#include "osaf/consensus/keyvalue.h"
 
 class Consensus {
-public:
-
+ public:
   // Obtain lock, set active controller to this node
   SaAisErrorT BeginActivePromotion();
 
@@ -47,20 +47,26 @@ public:
   // Is consensus service enabled?
   bool IsEnabled() const;
 
-  explicit Consensus();
+  // Is the key-value store writable?
+  bool IsWritable() const;
+
+  Consensus();
   virtual ~Consensus();
 
   Consensus(const Consensus&) = delete;
   Consensus& operator=(const Consensus&) = delete;
 
-private:
+ private:
   bool use_consensus_ = false;
   bool use_remote_fencing_ = false;
   const std::string keyname = "opensaf_active_controller";
-  static constexpr int sleep_internal = 100000; // in us
-
-  SaAisErrorT Demote(const std::string node);
+  const std::string test_keyname = "opensaf_write_test";
+  const std::chrono::milliseconds kSleepInterval =
+    std::chrono::milliseconds(100);  // in ms
+  static constexpr uint32_t kLockTimeout = 30;
+  static constexpr uint32_t kMaxRetry = 600;
+  SaAisErrorT Demote(const std::string& node);
   bool FenceNode(const std::string& node);
 };
 
-#endif
+#endif  // OSAF_CONSENSUS_SERVICE_H_
diff --git a/src/rde/rded/role.cc b/src/rde/rded/role.cc
index 28e034c44..a33137054 100644
--- a/src/rde/rded/role.cc
+++ b/src/rde/rded/role.cc
@@ -28,6 +28,7 @@
 #include "base/process.h"
 #include "base/time.h"
 #include "base/ncs_main_papi.h"
+#include "base/ncssysf_def.h"
 #include "rde/rded/rde_cb.h"
 #include "osaf/consensus/service.h"
 
@@ -85,7 +86,7 @@ timespec* Role::Poll(timespec* ts) {
       rc = consensus_service.BeginActivePromotion();
       if (rc != SA_AIS_OK) {
         LOG_ER("Unable to set active controller in consensus service");
-        LOG_ER("Split brain is possible");
+        opensaf_reboot(0, nullptr, "Unable to set active controller in consensus service");
       }
 
       ExecutePreActiveScript();
