Move copyBytes closer to use-sites
Move some test-only code into the test
Get rid of un-needed lock