Fix caching and compiling terminology, add unit tests