Bugfix and improved testing of chunk decoder.