fixed routing, refactored exceptions, added tests

There are other odds and ends in this commit...fixing one thing broke another, etc.