Add basic tests and related fixes