rtc: move and reorder, added unit test