Add tests for getting called as class method

And some general cleanup, e.g. only use lib when needed