Fixed kappa calculation so that it passes unit tests. Mostly by making the code more similar to yorchopolis's.