Refactor bytes & unicode (de)serialization API

Add tests that check for invalid input