Fix tests
Merge pull request #1843 from erwinwinder/master

Fix tests
Merge pull request #1842 from jjettenn/master

Fix previous merge! Refactor code.