Test improved and related bugs fixed.