I have raised and fixed issue
https://bugs.launchpad.net/calibre/+bug/1221035. This should be in the next calibre release. This only a partial fix for this problem. It fixes the corruption that is happening when the kepub file is copied to the library. But, it is copied and added as an ePub. To have it added as a kepub needs extra function added to calibre.