Issue #136 - Bug fixes, added test cases