Fix error with pin try + Add unit tests