Improve sanitization and add more tests