Update and refactor unit tests