Made toString more idiomatic and added test.