added tests and code to cover github issue #70