Fixed bad FIFO accesses, and bad length argument in test program

A remaining defect is that the sample program doesn't wait until the TX
worker consumes the samples before shutting down.