Add tests for prefetch subsystem; fix bugs