Fix problem when ASIN and SearchIndex were both given.
Switch output to JSON.
Refactor code.
Add some more tests.