Fix edge case behavior of nextTokenOnChannel and previousTokenOnChannel (fixes #622, fixes #544)