tests for core

Includes lots of tests for core. Moves hook stuff out of engine and into core,
where it really does belong.