Add and refactor some tests