merge test code from #2003