add self-closing view tests and fix bugs