AF will look for the highest contrast to lock onto. In this test that
might have been the edge of the battery, not the center. The other possibility is that you have a slight front focus / back focus and need to fine tune. Since you have the k-5 this is easily done.
Set up as you have with camera on tripod, make sure everything is aligned. The center of the lens needs to be perfectly horizontal to the target and aligned vertically. Any slight deviation from alignment renders the test inaccurate and will probably end up making your focus worse not better. Find a better focus target, batteries are OK for a quick test but not accurate enough for fine tuning. Several charts are available on the web (Google focus chart) or use a ruler at a 45 degree angle.
Take a series of shots to test. I take a few shots manually focused, then a few using live view and zooming in and then a few using the viewfinder AF system. When all three methods agree then you know you have everything adjusted correctly.
The live view will be the most accurate so I use that as the standard to adjust to. Once you have your shots go to the computer and compare; is there a difference in the shots using live view and using the view finder AF? If so which way? Is the focus point closer or farther away? Once you have this go into the camera menu and go to menu Custom - 4 option 26. You can set adjustments for up to 20 different lenses on the k-5. Make the adjustment, a little at a time and retest. Repeat until live view focus and viewfinder AF agree.
Please take your time and retest multiple times, this is not an exact science and you can make it worse if you just jump in and start changing things.
I use a Spyder LensCal system
Amazon.com: Datacolor DC SLC100 SpyderLensCal Lens Calibration System: Camera & Photo but the homemade system will work just fine if you take your time and double check everything.