Added test coverage and cleanup.