#47 better test coverage + bug fixes