Adds support for mac os (same impl. as linux)

Added support for Mac. Same implementation as for Linux, so refactored the code to read `nixExecutable`. 
Added tests for this as well, but as the implementation is the same, there are some duplicated tests, but I couldn't find a good way of asserting Mac support without duplicating.