Small, but important fixes in select subs; tests improvements