Adding NPM state handler

This is also how I'd like to test libraries in the future, so that we needn't ignore this code.