Added many more tests. See testing.R for details