Added tests, improved EnsureSubdomain#matches, and removed whitespace