write tests for this