Add tests from JSR-166 for COW data structures. Fix one bug found and ad...

...d null checks to match contracts