add tests, fix bucket bucketio->io, reduce duplication