Merge refactored tests from branch upstream-merge