Issue 351 unittests

Manuel:

Please review and merge.
Thanks,
Yuyi