improve test coverage + fixes bug #40 and #48