diff --git a/quad/scripts/tests/test_communication.rb b/quad/scripts/tests/test_communication.rb
index 5f562c48f394c44589e1aa22063d5f05ea62c5d2..4887a29bca60829b2a4bf4691a5c9de0e9fe546d 100644
--- a/quad/scripts/tests/test_communication.rb
+++ b/quad/scripts/tests/test_communication.rb
@@ -53,7 +53,28 @@ Timeout::timeout(30) {
         send_packet [0xBE, 1, 0, 0, 0, 0, 0, 0xBF]
       }
 
-      msg = recv_packet
+      fifo = File.open(UART_TX)
+
+      # Receive the header
+      msg = []
+      for i in 1..7
+        sleep 0.0001
+        c = fifo.read(1)
+        msg.push(c)
+      end
+
+      # Receive the remaining data, according to the header specified length
+      length = msg[5..7].join().unpack("S")[0]
+
+      msg = []
+      for i in 1..length
+        sleep 0.0001
+        c = fifo.read(1)
+        msg.push(c)
+      end
+      fifo.close
+
+      msg = msg.join()
       puts msg
       assert_equal(msg.force_encoding("UTF-8"), "Packets received: #{j}")
     end
diff --git a/quad/scripts/tests/test_logging.rb b/quad/scripts/tests/test_logging.rb
new file mode 100644
index 0000000000000000000000000000000000000000..a0e86e716eb4ccd71435b0f88a16f40e7f40e712
--- /dev/null
+++ b/quad/scripts/tests/test_logging.rb
@@ -0,0 +1,117 @@
+#!/usr/bin/env ruby
+
+# Logging test
+#
+# Let the quad fly for a bit, and then ensure we can
+# get its logs
+
+script_dir = File.expand_path(File.dirname(__FILE__))
+require script_dir + "/testing_library"
+
+bin_dir = script_dir + "/../../bin/"
+Dir.chdir(bin_dir)
+
+Timeout::timeout(30) {
+
+  puts("Setting up...")
+
+  # Start virtual quad
+  quad_pid = Process.spawn("./virt-quad -q",
+                           { :rlimit_as => 536870912, # 512 MiB total RAM
+                             :rlimit_stack => 1048576}) # 1 MiB stack
+
+  sleep 0.5
+
+  # Set RC switches
+  set_gear GEAR_OFF
+  set_flap FLAP_OFF
+
+  # Set initial quad orientation (flat on the ground, facing forward)
+  `./virt-quad set i2c_imu_x 0`
+  `./virt-quad set i2c_imu_y 0`
+  `./virt-quad set i2c_imu_z -1`
+  `./virt-quad set rc_roll 0.498`
+  `./virt-quad set rc_pitch 0.497`
+  `./virt-quad set rc_yaw 0.498`
+
+
+  #################
+  #  Begin Tests
+  #################
+
+  begin
+
+    puts "------------------------------------------"
+    puts "-- Beginning logging test..."
+    puts "------------------------------------------"
+
+    # Set initial quad orientation (flat on ground, facing forward)
+    `./virt-quad set i2c_imu_x 0`
+    `./virt-quad set i2c_imu_y 0`
+    `./virt-quad set i2c_imu_z -1`
+    `./virt-quad set rc_roll 0.498`
+    `./virt-quad set rc_pitch 0.497`
+    `./virt-quad set rc_yaw 0.498`
+
+    puts("Turning on GEAR...")
+    set_gear GEAR_ON
+    set_flap FLAP_ON
+    sleep 0.015
+
+    puts("Increasing Thrust to half maximum...")
+    for i in (THROTTLE_MIN..THROTTLE_MID).step(0.01)
+      set_throttle(i)
+      sleep 0.005
+    end
+
+    puts("Hovering for 3 seconds")
+    sleep 3
+
+    puts("Switching to autonomous and hovering for 3 seconds")
+    set_flap FLAP_OFF
+    sleep 3
+
+    puts("Switch back to manual, relaxing thrust to zero")
+    set_flap FLAP_ON
+    i = THROTTLE_MID
+    while i > THROTTLE_MIN
+      i -= 0.01
+      set_throttle(i)
+      sleep 0.005
+    end
+
+    # Get logs
+
+    Thread.new {
+      sleep 0.5
+      puts("Swiching off GEAR...")
+      set_gear GEAR_OFF
+    }
+
+    logs = []
+
+    begin
+      while true
+        logs.push(recv_packet)
+      end
+    rescue Timeout::Error
+      puts "No logs left"
+    end
+
+    if logs.length == 2
+      log_data = logs[1].split("\n")
+      for data in log_data
+        puts data
+      end
+      p log_data.length
+    end
+
+    puts "------------------------------------------"
+
+  ensure
+
+    Process.kill(9, quad_pid)
+    Process.wait(quad_pid)
+
+  end
+}
diff --git a/quad/scripts/tests/test_memory_integrity.rb b/quad/scripts/tests/test_memory_integrity.rb
index 31de3a763a43c727e57d9f352e2ec81a49dd8c27..d7116c1d4f2d3cd1d59e33824225c5f127c70c44 100644
--- a/quad/scripts/tests/test_memory_integrity.rb
+++ b/quad/scripts/tests/test_memory_integrity.rb
@@ -52,11 +52,11 @@ begin
   sleep 3
 
   puts("Switching to autonomous and hovering for 3 seconds")
-  set_flap FLAP_ON
+  set_flap FLAP_OFF
   sleep 3
 
   puts("Switch back to manual, relaxing thrust to zero")
-  set_flap FLAP_OFF
+  set_flap FLAP_ON
   i = THROTTLE_MID
   while i > THROTTLE_MIN
     i -= 0.01
@@ -67,11 +67,14 @@ begin
   puts("Swiching off GEAR...")
   set_gear GEAR_OFF
 
+  sleep 3
+
+  set_throttle THROTTLE_MIN
+
   puts("Flight ended successfully.");
 ensure
 
   Process.kill(2, quad)
-
   sleep 1 # wait for valgrind to write to file
 
   # Process the valgrind file
diff --git a/quad/scripts/tests/testing_library.rb b/quad/scripts/tests/testing_library.rb
index 524ef76cafff1a2de9b3303707cd9eb484b935a6..aad1ba85660bc1f2d2a9e50dfbeacc4a8243e08e 100644
--- a/quad/scripts/tests/testing_library.rb
+++ b/quad/scripts/tests/testing_library.rb
@@ -72,22 +72,25 @@ def send_packet(bytes)
 end
 
 def recv_packet
-  fifo = File.open(UART_TX)
+  fifo = nil
+  Timeout::timeout(5) {
+    fifo = File.open(UART_TX)
+  }
 
   # Receive the header
   msg = []
   for i in 1..7
-    sleep 0.010
     c = fifo.read(1)
     msg.push(c)
   end
 
   # Receive the remaining data, according to the header specified length
   length = msg[5..7].join().unpack("S")[0]
+
   msg = []
   for i in 1..length
-    sleep 0.010
-    msg.push(fifo.read(1))
+    c = fifo.read(1)
+    msg.push(c)
   end
   fifo.close
 
diff --git a/quad/src/virt_quad/hw_impl_unix_uart.c b/quad/src/virt_quad/hw_impl_unix_uart.c
index e39fbedfc06f93a75a8e682cb44d81be98f790bf..e750b29721faeef14b1dd60ec00c50eae00f3421 100644
--- a/quad/src/virt_quad/hw_impl_unix_uart.c
+++ b/quad/src/virt_quad/hw_impl_unix_uart.c
@@ -30,8 +30,8 @@ int unix_uart_write(struct UARTDriver *self, unsigned char c) {
   if (fifo >= 0) {
     printf("%s: %x\n", "uart-tx", c);
     write(fifo, &c, 1);
+    close(fifo);
   }
-  close(fifo);
   return 0;
 }