Added some initial tests, fixed a few minor issues.