courseware/views.py index function unicode error correction and test

@adampalay @sarina 

https://edx-wiki.atlassian.net/browse/LMS-2488

The unicode input now correctly results in a 404 error instead of a 500 error.
Genereally too we prefer to use `with self.assertRaises(...)` instead of `self.assertRaises` as it is clearer. You can do a `$ git grep with self.assertRaises` to quickly see where we use this.