fixes #99 , including tests