TODO update
Moved crc check into separate function, fixed unit tests
Moved header loading and decoding into separate function, few fixes in memory alloc
freed header