Bugfix for waveform plotting.

There a slight error in the data binning. It always occurred but only
manifested for certain data lenghts. Also added a test for it.