Added code to calculate permutations and some simple tests.