Fixed a bunch of problems with the arduino communications

library which were identified via unit testing. Solved some race
conditions during arduino communication shutdown and validated that
arduino enumeration is working correctly! (finally)

Improved the detection of arduino disconnects.