Fix lock.go to compile with Go 1.0

Refactor the code to be easier to read whilst we're at it.

Also fix a typo in a comment.
to export functions with cgo, they must be public
gccgo + cgo can't call static inline functions
Remove Finalize from the tests

Running Finalize in the tests means that sometimes the Initialize
takes forever ... so let's not do that.