buffet: Fix crash when CommandInstance::SetResults() is invoked

The crash was a result of use-after-delete in
CloudCommandProxy::OnResultsChanged() where TypedValueToJson returned
std::unique_ptr while the JSON value was set to Dictionary by using
unique_ptr::get() on the temporary. Should have called release()
instead to transfer the ownership to the dictionary.

Added a unit test to buffet/device_registration_info_unittest.cc to
test this specific scenario.

BUG=brillo:770
TEST=`FEATURES=test emerge-link buffet`

Change-Id: I34a28ce610a06f2b77af1cc75e358b3fb3562a13
Reviewed-on: https://chromium-review.googlesource.com/264465
Trybot-Ready: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/commands/command_manager.cc b/buffet/commands/command_manager.cc
index afdd518..f7533ca 100644
--- a/buffet/commands/command_manager.cc
+++ b/buffet/commands/command_manager.cc
@@ -26,6 +26,10 @@
   command_queue_.SetCommandDispachInterface(&command_dispatcher_);
 }
 
+CommandManager::CommandManager(CommandDispachInterface* dispatch_interface) {
+  command_queue_.SetCommandDispachInterface(dispatch_interface);
+}
+
 const CommandDictionary& CommandManager::GetCommandDictionary() const {
   return dictionary_;
 }