Added many more tests, much better code coverage now, but some failing / incomplete, fixed bugs uncovered by new tests