Fixes PCA (issue #13) and adds necessary tests