Add in view tests, refactor some internals