VOL-1577 - General cleanup (gofmt, go vet, go test, dep check)

Change-Id: I536b2746b8bd266f3e75aeccc65bfe7468f1b44a
diff --git a/db/kvstore/etcdclient.go b/db/kvstore/etcdclient.go
index 0b97039..6935296 100644
--- a/db/kvstore/etcdclient.go
+++ b/db/kvstore/etcdclient.go
@@ -455,6 +455,7 @@
 func (c *EtcdClient) AcquireLock(lockName string, timeout int) error {
 	duration := GetDuration(timeout)
 	ctx, cancel := context.WithTimeout(context.Background(), duration)
+	defer cancel()
 	session, _ := v3Concurrency.NewSession(c.ectdAPI, v3Concurrency.WithContext(ctx))
 	mu := v3Concurrency.NewMutex(session, "/devicelock_"+lockName)
 	if err := mu.Lock(context.Background()); err != nil {
@@ -462,7 +463,6 @@
 		return err
 	}
 	c.addLockName(lockName, mu, session)
-	cancel()
 	return nil
 }
 
diff --git a/db/model/base_test.go b/db/model/base_test.go
index 9d8a1a9..623d24b 100644
--- a/db/model/base_test.go
+++ b/db/model/base_test.go
@@ -33,28 +33,32 @@
 	DbTimeout int
 }
 
-func commonCallback(args ...interface{}) interface{} {
-	log.Infof("Running common callback - arg count: %s", len(args))
+var callbackMutex sync.Mutex
+
+func commonChanCallback(args ...interface{}) interface{} {
+	log.Infof("Running common callback - arg count: %d", len(args))
 
 	//for i := 0; i < len(args); i++ {
 	//	log.Infof("ARG %d : %+v", i, args[i])
 	//}
 
-	mutex := sync.Mutex{}
-	mutex.Lock()
-	defer mutex.Unlock()
+	callbackMutex.Lock()
+	defer callbackMutex.Unlock()
 
-	execStatus := args[1].(*bool)
+	execDoneChan := args[1].(*chan struct{})
 
 	// Inform the caller that the callback was executed
-	*execStatus = true
-	log.Infof("Changed value of exec status to true - stack:%s", string(debug.Stack()))
+	if *execDoneChan != nil {
+		log.Infof("Sending completion indication - stack:%s", string(debug.Stack()))
+		close(*execDoneChan)
+		*execDoneChan = nil
+	}
 
 	return nil
 }
 
 func commonCallback2(args ...interface{}) interface{} {
-	log.Infof("Running common2 callback - arg count: %s %+v", len(args), args)
+	log.Infof("Running common2 callback - arg count: %d %+v", len(args), args)
 
 	return nil
 }
diff --git a/db/model/node.go b/db/model/node.go
index 3908c4e..7bfdca0 100644
--- a/db/model/node.go
+++ b/db/model/node.go
@@ -309,8 +309,7 @@
 
 	// If there is not request to reconcile, try to get it from memory
 	if !reconcile {
-		if result = n.getPath(rev.GetBranch().GetLatest(), path, depth);
-			result != nil && reflect.ValueOf(result).IsValid() && !reflect.ValueOf(result).IsNil() {
+		if result = n.getPath(rev.GetBranch().GetLatest(), path, depth); result != nil && reflect.ValueOf(result).IsValid() && !reflect.ValueOf(result).IsNil() {
 			return result
 		}
 	}
@@ -577,7 +576,6 @@
 
 		return rev
 	}
-
 	return branch.GetLatest()
 }
 
diff --git a/db/model/non_persisted_revision.go b/db/model/non_persisted_revision.go
index d501c66..0ccc58e 100644
--- a/db/model/non_persisted_revision.go
+++ b/db/model/non_persisted_revision.go
@@ -440,4 +440,3 @@
 func (pr *NonPersistedRevision) StorageDrop(txid string, includeConfig bool) {
 	// stub ... required by interface
 }
-
diff --git a/db/model/persisted_revision.go b/db/model/persisted_revision.go
index cf7ff9e..a56b776 100644
--- a/db/model/persisted_revision.go
+++ b/db/model/persisted_revision.go
@@ -33,9 +33,9 @@
 	Revision
 	Compress bool
 
-	events    chan *kvstore.Event `json:"-"`
-	kvStore   *Backend            `json:"-"`
-	mutex     sync.RWMutex        `json:"-"`
+	events    chan *kvstore.Event
+	kvStore   *Backend
+	mutex     sync.RWMutex
 	isStored  bool
 	isWatched bool
 }
@@ -472,4 +472,4 @@
 	}
 
 	return response
-}
\ No newline at end of file
+}
diff --git a/db/model/proxy.go b/db/model/proxy.go
index eb3cb71..b45fb1d 100644
--- a/db/model/proxy.go
+++ b/db/model/proxy.go
@@ -248,7 +248,7 @@
 		pac.getProxy().Operation = op
 	}(PROXY_GET)
 
-	log.Debugw("proxy-operation--update", log.Fields{"operation":p.Operation})
+	log.Debugw("proxy-operation--update", log.Fields{"operation": p.Operation})
 
 	return pac.Update(fullPath, data, strict, txid, controlled)
 }
@@ -285,7 +285,7 @@
 
 	pac.SetProxy(p)
 
-	log.Debugw("proxy-operation--add", log.Fields{"operation":p.Operation})
+	log.Debugw("proxy-operation--add", log.Fields{"operation": p.Operation})
 
 	return pac.Add(fullPath, data, txid, controlled)
 }
@@ -319,7 +319,7 @@
 		p.Operation = PROXY_GET
 	}()
 
-	log.Debugw("proxy-operation--add", log.Fields{"operation":p.Operation})
+	log.Debugw("proxy-operation--add", log.Fields{"operation": p.Operation})
 
 	return pac.Add(fullPath, data, txid, controlled)
 }
@@ -353,7 +353,7 @@
 		p.Operation = PROXY_GET
 	}()
 
-	log.Debugw("proxy-operation--remove", log.Fields{"operation":p.Operation})
+	log.Debugw("proxy-operation--remove", log.Fields{"operation": p.Operation})
 
 	return pac.Remove(fullPath, txid, controlled)
 }
@@ -388,7 +388,7 @@
 		p.Operation = PROXY_GET
 	}()
 
-	log.Debugw("proxy-operation--create-proxy", log.Fields{"operation":p.Operation})
+	log.Debugw("proxy-operation--create-proxy", log.Fields{"operation": p.Operation})
 
 	return pac.CreateProxy(fullPath, exclusive, controlled)
 }
diff --git a/db/model/proxy_load_test.go b/db/model/proxy_load_test.go
index 47df98c..f44a6ae 100644
--- a/db/model/proxy_load_test.go
+++ b/db/model/proxy_load_test.go
@@ -43,7 +43,7 @@
 }
 type proxyLoadTest struct {
 	sync.RWMutex
-	addedDevices       [] string
+	addedDevices       []string
 	updatedFirmwares   []proxyLoadChanges
 	updatedFlows       []proxyLoadChanges
 	preAddExecuted     bool
diff --git a/db/model/proxy_test.go b/db/model/proxy_test.go
index 1e93243..f583b99 100644
--- a/db/model/proxy_test.go
+++ b/db/model/proxy_test.go
@@ -27,6 +27,7 @@
 	"reflect"
 	"strconv"
 	"testing"
+	"time"
 )
 
 var (
@@ -110,24 +111,31 @@
 	TestProxy_DeviceId = "0001" + hex.EncodeToString(devIDBin)[:12]
 	TestProxy_Device.Id = TestProxy_DeviceId
 
-	preAddExecuted := false
-	postAddExecuted := false
+	preAddExecuted := make(chan struct{})
+	postAddExecuted := make(chan struct{})
+	preAddExecutedPtr, postAddExecutedPtr := preAddExecuted, postAddExecuted
 
 	devicesProxy := TestProxy_Root.node.CreateProxy("/devices", false)
 	devicesProxy.RegisterCallback(PRE_ADD, commonCallback2, "PRE_ADD Device container changes")
 	devicesProxy.RegisterCallback(POST_ADD, commonCallback2, "POST_ADD Device container changes")
 
 	// Register ADD instructions callbacks
-	TestProxy_Root_Device.RegisterCallback(PRE_ADD, commonCallback, "PRE_ADD instructions", &preAddExecuted)
-	TestProxy_Root_Device.RegisterCallback(POST_ADD, commonCallback, "POST_ADD instructions", &postAddExecuted)
+	TestProxy_Root_Device.RegisterCallback(PRE_ADD, commonChanCallback, "PRE_ADD instructions", &preAddExecutedPtr)
+	TestProxy_Root_Device.RegisterCallback(POST_ADD, commonChanCallback, "POST_ADD instructions", &postAddExecutedPtr)
 
-	// Add the device
 	if added := TestProxy_Root_Device.Add("/devices", TestProxy_Device, ""); added == nil {
 		t.Error("Failed to add device")
 	} else {
 		t.Logf("Added device : %+v", added)
 	}
 
+	if !verifyGotResponse(preAddExecuted) {
+		t.Error("PRE_ADD callback was not executed")
+	}
+	if !verifyGotResponse(postAddExecuted) {
+		t.Error("POST_ADD callback was not executed")
+	}
+
 	// Verify that the added device can now be retrieved
 	if d := TestProxy_Root_Device.Get("/devices/"+TestProxy_DeviceId, 0, false, ""); !reflect.ValueOf(d).IsValid() {
 		t.Error("Failed to find added device")
@@ -135,33 +143,41 @@
 		djson, _ := json.Marshal(d)
 		t.Logf("Found device: %s", string(djson))
 	}
-
-	if !preAddExecuted {
-		t.Error("PRE_ADD callback was not executed")
-	}
-	if !postAddExecuted {
-		t.Error("POST_ADD callback was not executed")
-	}
 }
 
 func TestProxy_1_1_2_Add_ExistingDevice(t *testing.T) {
 	TestProxy_Device.Id = TestProxy_DeviceId
 
-	added := TestProxy_Root_Device.Add("/devices", TestProxy_Device, "");
+	added := TestProxy_Root_Device.Add("/devices", TestProxy_Device, "")
 	if added.(proto.Message).String() != reflect.ValueOf(TestProxy_Device).Interface().(proto.Message).String() {
 		t.Errorf("Devices don't match - existing: %+v returned: %+v", TestProxy_LogicalDevice, added)
 	}
 }
 
+func verifyGotResponse(callbackIndicator <-chan struct{}) bool {
+	timeout := time.After(1 * time.Second)
+	// Wait until the channel closes, or we time out
+	select {
+	case <-callbackIndicator:
+		// Received response successfully
+		return true
+
+	case <-timeout:
+		// Got a timeout! fail with a timeout error
+		return false
+	}
+}
+
 func TestProxy_1_1_3_Add_NewAdapter(t *testing.T) {
 	TestProxy_AdapterId = "test-adapter"
 	TestProxy_Adapter.Id = TestProxy_AdapterId
-	preAddExecuted := false
-	postAddExecuted := false
+	preAddExecuted := make(chan struct{})
+	postAddExecuted := make(chan struct{})
+	preAddExecutedPtr, postAddExecutedPtr := preAddExecuted, postAddExecuted
 
 	// Register ADD instructions callbacks
-	TestProxy_Root_Adapter.RegisterCallback(PRE_ADD, commonCallback, "PRE_ADD instructions for adapters", &preAddExecuted)
-	TestProxy_Root_Adapter.RegisterCallback(POST_ADD, commonCallback, "POST_ADD instructions for adapters", &postAddExecuted)
+	TestProxy_Root_Adapter.RegisterCallback(PRE_ADD, commonChanCallback, "PRE_ADD instructions for adapters", &preAddExecutedPtr)
+	TestProxy_Root_Adapter.RegisterCallback(POST_ADD, commonChanCallback, "POST_ADD instructions for adapters", &postAddExecutedPtr)
 
 	// Add the adapter
 	if added := TestProxy_Root_Adapter.Add("/adapters", TestProxy_Adapter, ""); added == nil {
@@ -170,6 +186,8 @@
 		t.Logf("Added adapter : %+v", added)
 	}
 
+	verifyGotResponse(postAddExecuted)
+
 	// Verify that the added device can now be retrieved
 	if d := TestProxy_Root_Adapter.Get("/adapters/"+TestProxy_AdapterId, 0, false, ""); !reflect.ValueOf(d).IsValid() {
 		t.Error("Failed to find added adapter")
@@ -178,10 +196,10 @@
 		t.Logf("Found adapter: %s", string(djson))
 	}
 
-	if !preAddExecuted {
+	if !verifyGotResponse(preAddExecuted) {
 		t.Error("PRE_ADD callback was not executed")
 	}
-	if !postAddExecuted {
+	if !verifyGotResponse(postAddExecuted) {
 		t.Error("POST_ADD callback was not executed")
 	}
 }
@@ -209,8 +227,10 @@
 
 func TestProxy_1_3_1_Update_Device(t *testing.T) {
 	var fwVersion int
-	preUpdateExecuted := false
-	postUpdateExecuted := false
+
+	preUpdateExecuted := make(chan struct{})
+	postUpdateExecuted := make(chan struct{})
+	preUpdateExecutedPtr, postUpdateExecutedPtr := preUpdateExecuted, postUpdateExecuted
 
 	if retrieved := TestProxy_Root_Device.Get("/devices/"+TestProxy_TargetDeviceId, 1, false, ""); retrieved == nil {
 		t.Error("Failed to get device")
@@ -228,13 +248,13 @@
 
 		TestProxy_Root_Device.RegisterCallback(
 			PRE_UPDATE,
-			commonCallback,
-			"PRE_UPDATE instructions (root proxy)", &preUpdateExecuted,
+			commonChanCallback,
+			"PRE_UPDATE instructions (root proxy)", &preUpdateExecutedPtr,
 		)
 		TestProxy_Root_Device.RegisterCallback(
 			POST_UPDATE,
-			commonCallback,
-			"POST_UPDATE instructions (root proxy)", &postUpdateExecuted,
+			commonChanCallback,
+			"POST_UPDATE instructions (root proxy)", &postUpdateExecutedPtr,
 		)
 
 		if afterUpdate := TestProxy_Root_Device.Update("/devices/"+TestProxy_TargetDeviceId, retrieved, false, ""); afterUpdate == nil {
@@ -243,19 +263,19 @@
 			t.Logf("Updated device : %+v", afterUpdate)
 		}
 
+		if !verifyGotResponse(preUpdateExecuted) {
+			t.Error("PRE_UPDATE callback was not executed")
+		}
+		if !verifyGotResponse(postUpdateExecuted) {
+			t.Error("POST_UPDATE callback was not executed")
+		}
+
 		if d := TestProxy_Root_Device.Get("/devices/"+TestProxy_TargetDeviceId, 1, false, ""); !reflect.ValueOf(d).IsValid() {
 			t.Error("Failed to find updated device (root proxy)")
 		} else {
 			djson, _ := json.Marshal(d)
 			t.Logf("Found device (root proxy): %s raw: %+v", string(djson), d)
 		}
-
-		if !preUpdateExecuted {
-			t.Error("PRE_UPDATE callback was not executed")
-		}
-		if !postUpdateExecuted {
-			t.Error("POST_UPDATE callback was not executed")
-		}
 	}
 }
 
@@ -265,18 +285,19 @@
 	flows := devFlowsProxy.Get("/", 0, false, "")
 	flows.(*openflow_13.Flows).Items[0].TableId = 2244
 
-	preUpdateExecuted := false
-	postUpdateExecuted := false
+	preUpdateExecuted := make(chan struct{})
+	postUpdateExecuted := make(chan struct{})
+	preUpdateExecutedPtr, postUpdateExecutedPtr := preUpdateExecuted, postUpdateExecuted
 
 	devFlowsProxy.RegisterCallback(
 		PRE_UPDATE,
-		commonCallback,
-		"PRE_UPDATE instructions (flows proxy)", &preUpdateExecuted,
+		commonChanCallback,
+		"PRE_UPDATE instructions (flows proxy)", &preUpdateExecutedPtr,
 	)
 	devFlowsProxy.RegisterCallback(
 		POST_UPDATE,
-		commonCallback,
-		"POST_UPDATE instructions (flows proxy)", &postUpdateExecuted,
+		commonChanCallback,
+		"POST_UPDATE instructions (flows proxy)", &postUpdateExecutedPtr,
 	)
 
 	kvFlows := devFlowsProxy.Get("/", 0, false, "")
@@ -291,6 +312,13 @@
 		t.Logf("Updated flows : %+v", updated)
 	}
 
+	if !verifyGotResponse(preUpdateExecuted) {
+		t.Error("PRE_UPDATE callback was not executed")
+	}
+	if !verifyGotResponse(postUpdateExecuted) {
+		t.Error("POST_UPDATE callback was not executed")
+	}
+
 	if d := devFlowsProxy.Get("/", 0, false, ""); d == nil {
 		t.Error("Failed to find updated flows (flows proxy)")
 	} else {
@@ -304,18 +332,12 @@
 		djson, _ := json.Marshal(d)
 		t.Logf("Found flows (root proxy): %s", string(djson))
 	}
-
-	if !preUpdateExecuted {
-		t.Error("PRE_UPDATE callback was not executed")
-	}
-	if !postUpdateExecuted {
-		t.Error("POST_UPDATE callback was not executed")
-	}
 }
 
 func TestProxy_1_3_3_Update_Adapter(t *testing.T) {
-	preUpdateExecuted := false
-	postUpdateExecuted := false
+	preUpdateExecuted := make(chan struct{})
+	postUpdateExecuted := make(chan struct{})
+	preUpdateExecutedPtr, postUpdateExecutedPtr := preUpdateExecuted, postUpdateExecuted
 
 	adaptersProxy := TestProxy_Root.node.CreateProxy("/adapters", false)
 
@@ -328,13 +350,13 @@
 
 		adaptersProxy.RegisterCallback(
 			PRE_UPDATE,
-			commonCallback,
-			"PRE_UPDATE instructions for adapters", &preUpdateExecuted,
+			commonChanCallback,
+			"PRE_UPDATE instructions for adapters", &preUpdateExecutedPtr,
 		)
 		adaptersProxy.RegisterCallback(
 			POST_UPDATE,
-			commonCallback,
-			"POST_UPDATE instructions for adapters", &postUpdateExecuted,
+			commonChanCallback,
+			"POST_UPDATE instructions for adapters", &postUpdateExecutedPtr,
 		)
 
 		if afterUpdate := adaptersProxy.Update("/"+TestProxy_AdapterId, retrieved, false, ""); afterUpdate == nil {
@@ -343,35 +365,36 @@
 			t.Logf("Updated adapter : %+v", afterUpdate)
 		}
 
+		if !verifyGotResponse(preUpdateExecuted) {
+			t.Error("PRE_UPDATE callback for adapter was not executed")
+		}
+		if !verifyGotResponse(postUpdateExecuted) {
+			t.Error("POST_UPDATE callback for adapter was not executed")
+		}
+
 		if d := TestProxy_Root_Adapter.Get("/adapters/"+TestProxy_AdapterId, 1, false, ""); !reflect.ValueOf(d).IsValid() {
 			t.Error("Failed to find updated adapter (root proxy)")
 		} else {
 			djson, _ := json.Marshal(d)
 			t.Logf("Found adapter (root proxy): %s raw: %+v", string(djson), d)
 		}
-
-		if !preUpdateExecuted {
-			t.Error("PRE_UPDATE callback for adapter was not executed")
-		}
-		if !postUpdateExecuted {
-			t.Error("POST_UPDATE callback for adapter was not executed")
-		}
 	}
 }
 
 func TestProxy_1_4_1_Remove_Device(t *testing.T) {
-	preRemoveExecuted := false
-	postRemoveExecuted := false
+	preRemoveExecuted := make(chan struct{})
+	postRemoveExecuted := make(chan struct{})
+	preRemoveExecutedPtr, postRemoveExecutedPtr := preRemoveExecuted, postRemoveExecuted
 
 	TestProxy_Root_Device.RegisterCallback(
 		PRE_REMOVE,
-		commonCallback,
-		"PRE_REMOVE instructions (root proxy)", &preRemoveExecuted,
+		commonChanCallback,
+		"PRE_REMOVE instructions (root proxy)", &preRemoveExecutedPtr,
 	)
 	TestProxy_Root_Device.RegisterCallback(
 		POST_REMOVE,
-		commonCallback,
-		"POST_REMOVE instructions (root proxy)", &postRemoveExecuted,
+		commonChanCallback,
+		"POST_REMOVE instructions (root proxy)", &postRemoveExecutedPtr,
 	)
 
 	if removed := TestProxy_Root_Device.Remove("/devices/"+TestProxy_DeviceId, ""); removed == nil {
@@ -379,19 +402,20 @@
 	} else {
 		t.Logf("Removed device : %+v", removed)
 	}
+
+	if !verifyGotResponse(preRemoveExecuted) {
+		t.Error("PRE_REMOVE callback was not executed")
+	}
+	if !verifyGotResponse(postRemoveExecuted) {
+		t.Error("POST_REMOVE callback was not executed")
+	}
+
 	if d := TestProxy_Root_Device.Get("/devices/"+TestProxy_DeviceId, 0, false, ""); reflect.ValueOf(d).IsValid() {
 		djson, _ := json.Marshal(d)
 		t.Errorf("Device was not removed - %s", djson)
 	} else {
 		t.Logf("Device was removed: %s", TestProxy_DeviceId)
 	}
-
-	if !preRemoveExecuted {
-		t.Error("PRE_REMOVE callback was not executed")
-	}
-	if !postRemoveExecuted {
-		t.Error("POST_REMOVE callback was not executed")
-	}
 }
 
 func TestProxy_2_1_1_Add_NewLogicalDevice(t *testing.T) {
@@ -400,12 +424,13 @@
 	TestProxy_LogicalDeviceId = "0001" + hex.EncodeToString(ldIDBin)[:12]
 	TestProxy_LogicalDevice.Id = TestProxy_LogicalDeviceId
 
-	preAddExecuted := false
-	postAddExecuted := false
+	preAddExecuted := make(chan struct{})
+	postAddExecuted := make(chan struct{})
+	preAddExecutedPtr, postAddExecutedPtr := preAddExecuted, postAddExecuted
 
 	// Register
-	TestProxy_Root_LogicalDevice.RegisterCallback(PRE_ADD, commonCallback, "PRE_ADD instructions", &preAddExecuted)
-	TestProxy_Root_LogicalDevice.RegisterCallback(POST_ADD, commonCallback, "POST_ADD instructions", &postAddExecuted)
+	TestProxy_Root_LogicalDevice.RegisterCallback(PRE_ADD, commonChanCallback, "PRE_ADD instructions", &preAddExecutedPtr)
+	TestProxy_Root_LogicalDevice.RegisterCallback(POST_ADD, commonChanCallback, "POST_ADD instructions", &postAddExecutedPtr)
 
 	if added := TestProxy_Root_LogicalDevice.Add("/logical_devices", TestProxy_LogicalDevice, ""); added == nil {
 		t.Error("Failed to add logical device")
@@ -413,6 +438,8 @@
 		t.Logf("Added logical device : %+v", added)
 	}
 
+	verifyGotResponse(postAddExecuted)
+
 	if ld := TestProxy_Root_LogicalDevice.Get("/logical_devices/"+TestProxy_LogicalDeviceId, 0, false, ""); !reflect.ValueOf(ld).IsValid() {
 		t.Error("Failed to find added logical device")
 	} else {
@@ -420,10 +447,10 @@
 		t.Logf("Found logical device: %s", string(ldJSON))
 	}
 
-	if !preAddExecuted {
+	if !verifyGotResponse(preAddExecuted) {
 		t.Error("PRE_ADD callback was not executed")
 	}
-	if !postAddExecuted {
+	if !verifyGotResponse(postAddExecuted) {
 		t.Error("POST_ADD callback was not executed")
 	}
 }
@@ -431,7 +458,7 @@
 func TestProxy_2_1_2_Add_ExistingLogicalDevice(t *testing.T) {
 	TestProxy_LogicalDevice.Id = TestProxy_LogicalDeviceId
 
-	added := TestProxy_Root_LogicalDevice.Add("/logical_devices", TestProxy_LogicalDevice, "");
+	added := TestProxy_Root_LogicalDevice.Add("/logical_devices", TestProxy_LogicalDevice, "")
 	if added.(proto.Message).String() != reflect.ValueOf(TestProxy_LogicalDevice).Interface().(proto.Message).String() {
 		t.Errorf("Logical devices don't match - existing: %+v returned: %+v", TestProxy_LogicalDevice, added)
 	}
@@ -461,8 +488,9 @@
 
 func TestProxy_2_3_1_Update_LogicalDevice(t *testing.T) {
 	var fwVersion int
-	preUpdateExecuted := false
-	postUpdateExecuted := false
+	preUpdateExecuted := make(chan struct{})
+	postUpdateExecuted := make(chan struct{})
+	preUpdateExecutedPtr, postUpdateExecutedPtr := preUpdateExecuted, postUpdateExecuted
 
 	if retrieved := TestProxy_Root_LogicalDevice.Get("/logical_devices/"+TestProxy_TargetLogicalDeviceId, 1, false, ""); retrieved == nil {
 		t.Error("Failed to get logical device")
@@ -478,13 +506,13 @@
 
 		TestProxy_Root_LogicalDevice.RegisterCallback(
 			PRE_UPDATE,
-			commonCallback,
-			"PRE_UPDATE instructions (root proxy)", &preUpdateExecuted,
+			commonChanCallback,
+			"PRE_UPDATE instructions (root proxy)", &preUpdateExecutedPtr,
 		)
 		TestProxy_Root_LogicalDevice.RegisterCallback(
 			POST_UPDATE,
-			commonCallback,
-			"POST_UPDATE instructions (root proxy)", &postUpdateExecuted,
+			commonChanCallback,
+			"POST_UPDATE instructions (root proxy)", &postUpdateExecutedPtr,
 		)
 
 		retrieved.(*voltha.LogicalDevice).RootDeviceId = strconv.Itoa(fwVersion)
@@ -495,6 +523,14 @@
 		} else {
 			t.Logf("Updated logical device : %+v", afterUpdate)
 		}
+
+		if !verifyGotResponse(preUpdateExecuted) {
+			t.Error("PRE_UPDATE callback was not executed")
+		}
+		if !verifyGotResponse(postUpdateExecuted) {
+			t.Error("POST_UPDATE callback was not executed")
+		}
+
 		if d := TestProxy_Root_LogicalDevice.Get("/logical_devices/"+TestProxy_TargetLogicalDeviceId, 1, false, ""); !reflect.ValueOf(d).IsValid() {
 			t.Error("Failed to find updated logical device (root proxy)")
 		} else {
@@ -502,13 +538,6 @@
 
 			t.Logf("Found logical device (root proxy): %s raw: %+v", string(djson), d)
 		}
-
-		if !preUpdateExecuted {
-			t.Error("PRE_UPDATE callback was not executed")
-		}
-		if !postUpdateExecuted {
-			t.Error("POST_UPDATE callback was not executed")
-		}
 	}
 }
 
@@ -557,18 +586,19 @@
 }
 
 func TestProxy_2_4_1_Remove_Device(t *testing.T) {
-	preRemoveExecuted := false
-	postRemoveExecuted := false
+	preRemoveExecuted := make(chan struct{})
+	postRemoveExecuted := make(chan struct{})
+	preRemoveExecutedPtr, postRemoveExecutedPtr := preRemoveExecuted, postRemoveExecuted
 
 	TestProxy_Root_LogicalDevice.RegisterCallback(
 		PRE_REMOVE,
-		commonCallback,
-		"PRE_REMOVE instructions (root proxy)", &preRemoveExecuted,
+		commonChanCallback,
+		"PRE_REMOVE instructions (root proxy)", &preRemoveExecutedPtr,
 	)
 	TestProxy_Root_LogicalDevice.RegisterCallback(
 		POST_REMOVE,
-		commonCallback,
-		"POST_REMOVE instructions (root proxy)", &postRemoveExecuted,
+		commonChanCallback,
+		"POST_REMOVE instructions (root proxy)", &postRemoveExecutedPtr,
 	)
 
 	if removed := TestProxy_Root_LogicalDevice.Remove("/logical_devices/"+TestProxy_LogicalDeviceId, ""); removed == nil {
@@ -576,19 +606,20 @@
 	} else {
 		t.Logf("Removed device : %+v", removed)
 	}
+
+	if !verifyGotResponse(preRemoveExecuted) {
+		t.Error("PRE_REMOVE callback was not executed")
+	}
+	if !verifyGotResponse(postRemoveExecuted) {
+		t.Error("POST_REMOVE callback was not executed")
+	}
+
 	if d := TestProxy_Root_LogicalDevice.Get("/logical_devices/"+TestProxy_LogicalDeviceId, 0, false, ""); reflect.ValueOf(d).IsValid() {
 		djson, _ := json.Marshal(d)
 		t.Errorf("Device was not removed - %s", djson)
 	} else {
 		t.Logf("Device was removed: %s", TestProxy_LogicalDeviceId)
 	}
-
-	if !preRemoveExecuted {
-		t.Error("PRE_REMOVE callback was not executed")
-	}
-	if !postRemoveExecuted {
-		t.Error("POST_REMOVE callback was not executed")
-	}
 }
 
 // -----------------------------
diff --git a/db/model/root.go b/db/model/root.go
index 7a29c0b..338ef67 100644
--- a/db/model/root.go
+++ b/db/model/root.go
@@ -181,7 +181,6 @@
 	r.Proxy.ParentNode.Latest(txid).Finalize(false)
 }
 
-
 // Update modifies the content of an object at a given path with the provided data
 func (r *root) Update(path string, data interface{}, strict bool, txid string, makeBranch MakeBranchFunction) Revision {
 	var result Revision
@@ -310,6 +309,6 @@
 }
 
 type rootData struct {
-	Latest string            `json:latest`
-	Tags   map[string]string `json:tags`
-}
\ No newline at end of file
+	Latest string            `json:"latest"`
+	Tags   map[string]string `json:"tags"`
+}
diff --git a/db/model/transaction_test.go b/db/model/transaction_test.go
index b6e324e..bc53791 100644
--- a/db/model/transaction_test.go
+++ b/db/model/transaction_test.go
@@ -36,6 +36,7 @@
 	TestTransaction_Root = NewRoot(&voltha.Voltha{}, nil)
 	TestTransaction_RootProxy = TestTransaction_Root.node.CreateProxy("/", false)
 }
+
 //func TestTransaction_1_GetDevices(t *testing.T) {
 //	getTx := TestTransaction_RootProxy.OpenTransaction()
 //
diff --git a/db/model/utils.go b/db/model/utils.go
index f0fd618..b28e92f 100644
--- a/db/model/utils.go
+++ b/db/model/utils.go
@@ -36,8 +36,8 @@
 
 // FindOwnerType will traverse a data structure and find the parent type of the specified object
 func FindOwnerType(obj reflect.Value, name string, depth int, found bool) reflect.Type {
- 	prefix := ""
-	for d:=0; d< depth; d++ {
+	prefix := ""
+	for d := 0; d < depth; d++ {
 		prefix += ">>"
 	}
 	k := obj.Kind()