Add unit tests for Recorder

Add unit tests for Recorder and refactor Record to make it testable