fixed middleware and updated tests to reflect bad requests (400 errors on bad input)
Merge pull request #142 from stealthycoin/fix_middleware

fixed middleware