Add further test coverage and refactor existing tests