Tests and bugfixes hm

Merge for fixes for #1, #7, #30, #31, #32 and #35