fix non-existent domains error; add tests