Fix code, remove warnings, and add test files