Address review comments, add tests