Implement package resolution and write tests