Fixed security issues spotted by tom@catalyst.net.nz .
Got the tests working.