Add and refactor tests