Added tests and possible fixes to Github Issue #6, and Issue #131