Modularize scale domains, add tests (#177).