Apply the unit test fix for #400 to master