Fix #9 & improve tests

close #9