flesh out unit tests, simplify some logic, add some todo's