use more idiomatic scala (no mutable hash maps, no string comparison in test cases, etc.)