Fixes and two more tests ported from Java.