Added more informative error/warning messages. Cleaned up some code and test files. Moved test files to new tests/testthat folder.