Unit fixes

putting suggested fix and code cleaning from PR72 into a separate pull request