adding middleware to check for valid ObjectId's
updating error handling and tests