Streamline and rewrite terst

* Consolidate everything into a single function, Is
* Stop using "unsafe"

This fixes issue #1