fix and provide test cases for #32 #33 #34