introduce bin_to_nibble_list and bin_to_nibble_list_with_terminator

this makes the code a bit easier to understand

['0123456789abcdef'.find(x) for x in bindata.encode('hex')] may be a bit
shorter but it hides the intention of the code.
caching of databases looks fishy, at least use absolute paths
use bitwise operations for encoding/decoding the first nibble

comparing with >= 2 isn't a natural way to check if the second bit is
set and it's also wrong if higher bits could be set