refactor code to use HLS objects
underrun and stale errors, as failures not exceptions
separated unit tests in to unit + integration
moved casts and errors to new files