Refactor lib/levelup.js

Hi,

The following has been done:

1. LevelUP( ) constructor and methods are put into a closure. The reason for this was to make this._options, this._location, this._status and this._db private instead of public properties, they should only be accessible by the internals of the object.

2. encodingOpts was moved to util.js to make it more clean.

3. setStatus( ) was added for better traceability

4. getKeyEncoding( ) and getValueEncoding( ) were added to clean up duplicate code

5. getOptions( ) and getCallback( ) were moved into the closure

6. location( ) was added as a method (so the tests can check the location) and obviously also became part of the API. Not sure if we should add this to the README though, but perhaps it might be useful to know which location a db object represents?

7. hasOptions( ) was added as a convenience method, since options is a private state. It takes an object and checks if the db has the same properties set on its internal options.

8. inLimbo( ) helper function was added to abstract !isOpen( ) && !isClosed( ), which corresponds to either the status 'new' or 'opening'. I chose this name because of the previous comments '// limbo, defer the operation', which were removed. It's better to explain the purpose of the code with the code, comments might grow old and useless.

All tests pass and the benchmarks are the same as the currently released 0.5.1

Cheers
/Magnus