Endpoint refactoring.

- Consolidates the generic handler with the actual endpoint handler for better utilization
- Cleanup and unit tests

Change-Id: I356217d19bde57767e6f0e2bd1eb6db882970c13