Review and episode tests

Finish test suite, couple of bug fixes. Also clear up some security and dependencies