Return 0 in case of invalid type of data

Do that for major type 0, 1 and 7. In case we don't have the expected
type of data in the stream, just return 0 instead of asserting.

Add tests