Problem: cannot generate from within CLASS src directory

Solution: use topdir argument to provide optional root for all
code generation, otherwise use current directory.
Problem: cannot deal with zero-sized msg on input

Solution: do not complain if msg is zero-sized; return empty
msg as one would expect.

Also, fixed memory leak in self test.
Problem: leaking memory on longstr field

Solution: free properly before re-allocating on message recv.
Merge pull request #151 from hintjens/master

Various fixes