Refactoring tests

This is the first branch that passes Travis. Features that were failing have been marked as pending. This should help with integrating others branches.